[PD] Idiomatic Pd

Frank Barknecht fbar at footils.org
Tue Jul 29 08:53:26 CEST 2008


Hallo,
Luke Iannini hat gesagt: // Luke Iannini wrote:

> On Mon, Jul 28, 2008 at 10:31 PM, Frank Barknecht <fbar at footils.org> wrote:
> >> Style:
> >> * If giving $0 as an argument to an abstraction, it is always first in
> >> the argument list [1]
> >
> > I often put it last (and it's specified to be that way e.g. in
> > Memento)
> My reasoning here is that $0 is probably the most common thing to pass
> to an abstraction, but abstractions have varying numbers of arguments,
> so $0 will sometimes be $3, sometimes $2, sometimes $7, and that
> swings my brain around.  Putting it in the first slot means that $1
> gains a sort of second meaning as "my parent's $0", which I think is
> handy.

The reason, $0 is last in e.g. [originator] or [commun] was that this
way I can pass $1 deeply without ever changing the number.

For example it's quite common to have something like this with memento 

[synth /mysynth]
  [envelope $1/myenv $0]
     [attack $1/a $0]

Here the toplevel [synth] doesn't need to pass $0. Putting the name as
second arg would make it look like this: 

[synth /mysynth]
  [envelope $0 $1/myenv]
     [attack $0 $2/a]

and now suddenly it depends on how deep I am in the hierarchy if I
should use $1 or $2. So generally with memento/sssad I reserve $1 to
be the "tag" of an object or the "self" in other languages, but that
tag generally doesn't refer to the parent's $0.

> And, the same memory-assistance applies to my numeric-ordering
> proposition as well; I usually remember how many arguments an
> abstraction has better than what order they're in, so when they're all
> taken from their parent I know it will be [mychild $0 $1 $2].

Yeah, numeric ordering is fine, but putting $0 first means, that using
$1 inside the abstraction is $0 from the parent, $2 inside the
abstraction is the value called $1, $3 = $2 and so on. Putting $0 last
lets you have $1 = $1, $2 = $2 and so on in abstraction
trees/hierarchies like above.

> That's all cool, and I think you are in the majority on that.  I think
> I just took camelCase because it reminded me of Smalltalk and Cocoa,
> which remind me of Pd : ).

Yep, it's just two different styles. Probably the style guide
shouldn't favour a single one but just recommend to not change the
style in one project. 

Btw. I tend to use ALL_UPPERCASE for globals.

Ciao
-- 
 Frank Barknecht                                     _ ______footils.org__




More information about the Pd-list mailing list