[PD] dealing with arguments and inlets
Hans-Christoph Steiner
hans at eds.org
Sat Feb 4 02:32:55 CET 2006
On Jan 31, 2006, at 6:16 AM, Frank Barknecht wrote:
> Hallo,
> Hans-Christoph Steiner hat gesagt: // Hans-Christoph Steiner wrote:
>
>> 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,
>
> "should match" would be oversimplyfiying, but having an extra inlet in
> the argument-patches never hurts.
>
>> 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]
>
> I attached "list_argument" which does the same as "any_argument" but
> doesn't require any externals and is much simpler than [any_arg...].
> In fact, it's just [float_argument] where "float" is replaced by "list
> append".
>
> Note that I would much prefer, if [list_argument] would be renamed to
> be [any_argument] and replace it.
>
> Reason is: The name "list_argument" could lead to wrong expectations:
> It doesn't
> handle variable length lists as arguments, because that is impossible
> without externals like dollarg. It just handles one-element lists
> which get auto-converted to their respective type: "symbol x" or
> "float x".
>
> Of course it won't work with Pd < 0.39.
>
> Regarding symbol_- and float_argument: These could be implemented as:
>
> [list_argument $1 $2] or [any_argument]
> |
> [route symbol] or [route float]
> |
> [outlet]
>
> to share more code. Because Pd autoconverts one-element lists, there
> will always be a proper selector to make [route] do The Right Thing.
>
I found one key difference between [any_argument] and [list_argument].
[any_argument] outputs a non-symbol, [list_argument] outputs a symbol.
So that means that if you want to handle messages like [word( with
[list_argument], there will have to be this after it:
[route symbol]
|
[route word]
Personally, I think its better having the argument not be a symbol
since its very likely that [route] will be involved soon after. Also,
for [list_argument], you'll need some extra logic on the convenience
inlet to make sure that the output on the [outlet] is always
consistent. I attached a version of [list_argument] with this extra
logic:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_argument.pd
Type: application/octet-stream
Size: 871 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20060203/ea123b89/attachment.obj>
-------------- next part --------------
[inlet]
|
[route float]
\ [symbol]
\ /
\ /
\ /
[outlet]
This gets into another definition question. What is the type in this
message: [word( Its not a "not-list list" since its not a list of any
kind. Pd itself doesn't call one element messages a "list". And a
"non-list element" would also include this: [5(. So I guess its an
"undefined element" to match "undefined lists".
So we have:
bang
float
symbol
list
pointer
undefined element
undefined list
I guess we should just coin words for these, like undelement and
undlist ;) Let's check the thesaurus for list: inventory; or element:
item, unit. Or how about this: "untyped list" and "untyped element".
.hc
________________________________________________________________________
____
"The arc of history bends towards justice."
- Dr. Martin Luther King, Jr.
More information about the Pd-list
mailing list