<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">What exactly would "this" (#4) look like in Pd?<br><br>-Jonathan<br><br>--- On <b>Wed, 12/15/10, brandon zeeb <i>&lt;zeeb.brandon@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: brandon zeeb &lt;zeeb.brandon@gmail.com&gt;<br>Subject: Re: [PD] PD OOP?<br>To: "PD List" &lt;pd-list@iem.at&gt;<br>Date: Wednesday, December 15, 2010, 1:51 PM<br><br><div id="yiv1051503545">In my experience with emulating OOP in Pd I've had moderate success.&nbsp; As a Java developer by day, I find myself attempting to recreate familiar patterns within Pd (ie: usually IoC and Flyweight in Pd).&nbsp;&nbsp; Main problems with recreating OOP in Pd are the following:<br>
<ol><li>Everything is global</li><li>No control over abstraction (object) construction order and lifecycle</li><li>No introspection (although not required, very helpful, and don't tell me it's in some external, I don't care!)</li>
<li>No concept of "this"</li><li>No interfaces or abstract abstractions (to control inlet patterns)</li><li>Unfriendly and inconsistent type system (it is cumbersome in real use, although I get over this by using [list])</li>
<li>and on and on</li></ol>In most Pd patches, I see people using a few lookup tables again and again (ie: mtof).&nbsp; As this is a complete waste of memory, one can attempt the Flyweight pattern.&nbsp; However, doing so in Pd is a very dangerous game, as you will have NO idea which abstraction first created the table and thus have no control over retaining access to it.&nbsp; In my library I've dropped this approach in favor of something closer to IoC.<br>
<br>Basic IoC is very possible, and indeed very rewarding.&nbsp; Very often I pass in other abstractions as object creation arguments.&nbsp; The most simple example of this in my library is my [bypass~] abstraction used to dynamically enable and disable a given abstraction.&nbsp; I use this EVERYWHERE to save CPU cycles in combination with another object to programmatically disable the sub-abstraction when the user selects a given value (ie: when the filter cutoff is at MAX with no resonance, disable the filter).<br>
<br>In use:<br><br>[bypass~ some_process~ 330 1 3 9]<br><br>Where [bypass~] expects it's 1st argument to be an abstraction and the next 10 to be arguments to that abstraction.&nbsp; Every patch which uses [bypass]~ must have 1 signal inlet and 1 event inlet.&nbsp; Unfortunately, this interface can't be programmatically enforced. [bypass~] passes it's 1st two inlets to the sub-abstraction, while the 3rd is used to control [bypass~]<br>
<br>I've attached [bypass~] and it's dependencies, have fun!<br><br>~Brandon<br>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br><a ymailto="mailto:Pd-list@iem.at" href="/mc/compose?to=Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br></div></blockquote></td></tr></table><br>