On Jan 31, 2006, at 2:02 PM, Stefan Turner wrote:
Message: 8 Date: Mon, 30 Jan 2006 19:03:09 -0500 From: Hans-Christoph Steiner hans@eds.org Subject: [PD] dealing with arguments and inlets To: PD-List List pd-list@iem.at Message-ID:
f800a0b7f1f7e6ccf418411ac1afacee@eds.org
Content-Type: text/plain; charset="us-ascii"
I have written some classes for handling arguments
when writing classes
in Pd. They are [float_argument],
[symbol_argument], and
[any_argument].
Currently, I am thinking in general, inlets should be
matched to arguments and vice versa, so these
objects all have a
"convenience" right inlet, to attach the [inlet] to
so that the data
all comes from the [*_argument] object.
To use them, you add the argument you want it to
handle like this:
[float_argument $1]
If you want a default value for when none is
specified, you would do it
like this:
[float_argument $2 234] [symbol_argument $3 default] [any_argument $9 asdf] [any_argument $5 444]
My goal is to make these a standard way of handling
arguments when
writing classes in Pd. What do y'all think?
This is a very cool idea. Virtually all my abstractions have an inlet and ii (from iem) for each argument: would definitely be better to have both in one.
Might it be better to go all the way and have these as externals which function as [inlet], but also support defaults as you've said? Obviously then it would be cool to keep the naming argument of [inlet], which appears when you hover.
Or alternatively to extend the built-in inlet to give the functionality you've said, while just behaving as currently if the extra arguments aren't given, e.g.:
[inlet] - as current [inlet name] - as current, with a name [inlet name $1] - as current, but at loadbang-time output $1 [inlet name $1 123] - as current, but at loadbang-time output $1, or 123 if $1 not specified
Don't know how you'd handle the separation of floats, symbols and anys then though...maybe add finlet and sinlet...??
I like keeping them separate because that means it can be written in
Pd, and the C objects are just the most primitive, like plain old
[inlet]. Plus you can use them separately, since inlets and arguments
are not one in the same...
.hc
"I have the audacity to believe that peoples everywhere can have three
meals a day for their bodies, education and culture for their minds,
and dignity, equality and freedom for their spirits."
- Martin Luther King, Jr.