Hi all,
Here's a design pattern for passing named arguments ("bar=true foo=12") into an abstraction.
Cheers,
Chris.
Hi Chris, I prefer the idea of using the comma atom to send messages to an object/abstraction at init time.
Example: [bar 15 25( | [foo]
would be equivalent to
[initbang] | [foo, bar 15 25] Benefits:
Drawbacks:
-Jonathan
On Thursday, October 23, 2014 11:28 PM, Chris McCormick chris@mccormick.cx wrote:
Hi all,
Here's a design pattern for passing named arguments ("bar=true foo=12") into an abstraction.
Cheers,
Chris.
Hi Jonathan,
I am probably confused, or confusing here, but I was suggesting this as a mechanism whereby the author of an abstraction could have the abstraction accept named arguments set by a user of the abstraction.
In that light I am confused by what you've written below, sorry about that! You seem to be specifying a way for an abstraction to set up internal defaults, is that right?
I don't have access to "initbang" in the Pd I use yet.
Cheers,
Chris.
On 24/10/14 12:11, Jonathan Wilkes via Pd-list wrote:
Hi Chris, I prefer the idea of using the comma atom to send messages to an object/abstraction at init time.
Example: [bar 15 25( | [foo]
would be equivalent to
[initbang] | [foo, bar 15 25]
Benefits:
- messages can be type-checked or arbitrary length, just like any pd message
- eases development of externals. For instance, sigmund~ would have had
96 fewer lines of code because this syntax would have done away with the need for flags
- it looks like message-box syntax and behaves nearly the same
- once implemented, it would automatically apply (consistently) to every
internal/external object
- matju already implemented it in Gridflow
Drawbacks:
- [expr], [list], [select], [route], and a few others would need to be
treated specially to retain their current behavior regarding commas
- abstractions require some mechanism to retrieve those init-time
messages. I believe matju had them shoot out the leftmost inlet of the abstraction, with the assumption that the user would have a [route] sitting there to parse them. Another idea would be to retrieve them from an introspection object like [canvasinfo] (and maybe have another object which splits that into a sequence of messages).
-Jonathan On Thursday, October 23, 2014 11:28 PM, Chris McCormick chris@mccormick.cx wrote:
Hi all,
Here's a design pattern for passing named arguments ("bar=true foo=12") into an abstraction.
Cheers,
Chris.
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
I think we're talking about the same thing.
In matju's scheme, the abstraction author can make it possible for a user to type something like this: [myabstraction, something 1 2 3, something_else blah]
After the objects inside myabstraction are instantiated, it would output this from the leftmost inlet inside the abstraction: something 1 2 3 something_else blah
Then the abstraction author can [route something something_else] in order to use those messages to initialize whatever they want inside the abstraction. I assume this is what would happen in your scheme after the final [route bang] to the outlet at the end of the patch.
In fact you can do this in Pd Vanilla and obviate the symbol parsing/conversion. Try this: [named-arguments foo bar, height 12, cats miaow look ma an arbitrary number of values for this last named "arg"]
Break the list into sequences using [sel,]. It works because Pd's parser converts the comma atoms to symbols consisting of an escaped comma.
And you don't need [initbang] to do any of this. It's just useful to describe functionality I'm talking about.
-Jonathan
On Friday, October 24, 2014 12:18 AM, Chris McCormick chris@mccormick.cx wrote:
Hi Jonathan,
I am probably confused, or confusing here, but I was suggesting this as a mechanism whereby the author of an abstraction could have the abstraction accept named arguments set by a user of the abstraction.
In that light I am confused by what you've written below, sorry about that! You seem to be specifying a way for an abstraction to set up internal defaults, is that right?
I don't have access to "initbang" in the Pd I use yet.
Cheers,
Chris.
On 24/10/14 12:11, Jonathan Wilkes via Pd-list wrote:
Hi Chris, I prefer the idea of using the comma atom to send messages to an object/abstraction at init time.
Example: [bar 15 25( | [foo]
would be equivalent to
[initbang] | [foo, bar 15 25]
Benefits:
- messages can be type-checked or arbitrary length, just like any pd message
- eases development of externals. For instance, sigmund~ would have had
96 fewer lines of code because this syntax would have done away with the need for flags
- it looks like message-box syntax and behaves nearly the same
- once implemented, it would automatically apply (consistently) to every
internal/external object
- matju already implemented it in Gridflow
Drawbacks:
- [expr], [list], [select], [route], and a few others would need to be
treated specially to retain their current behavior regarding commas
- abstractions require some mechanism to retrieve those init-time
messages. I believe matju had them shoot out the leftmost inlet of the abstraction, with the assumption that the user would have a [route] sitting there to parse them. Another idea would be to retrieve them from an introspection object like [canvasinfo] (and maybe have another object which splits that into a sequence of messages).
-Jonathan On Thursday, October 23, 2014 11:28 PM, Chris McCormick chris@mccormick.cx wrote:
Hi all,
Here's a design pattern for passing named arguments ("bar=true foo=12") into an abstraction.
Cheers,
Chris.
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hi,
On 24/10/14 12:47, Jonathan Wilkes via Pd-list wrote:
I think we're talking about the same thing.
In matju's scheme, the abstraction author can make it possible for a user to type something like this: [myabstraction, something 1 2 3, something_else blah]
Break the list into sequences using [sel,]. It works because Pd's parser converts the comma atoms to symbols consisting of an escaped comma.
Ok, that's great! Thanks for sharing.
Cheers,
Chris.
Hi,
Trying to follow this discussion, I opened Chris's [named-arguments-help.pd] and got these error messages from Pd-Extended 0.44:
list fromsymbol: unknown function list fromsymbol ... couldn't create list tosymbol: unknown function list tosymbol ... couldn't create
Can you use those arguments to [list]? How?
Katja
On Fri, Oct 24, 2014 at 7:21 AM, Chris McCormick chris@mccormick.cx wrote:
Hi,
On 24/10/14 12:47, Jonathan Wilkes via Pd-list wrote:
I think we're talking about the same thing.
In matju's scheme, the abstraction author can make it possible for a user to type something like this: [myabstraction, something 1 2 3, something_else blah]
Break the list into sequences using [sel,]. It works because Pd's parser converts the comma atoms to symbols consisting of an escaped
comma.
Ok, that's great! Thanks for sharing.
Cheers,
Chris.
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Fri, 2014-10-24 at 10:15 +0200, katja wrote:
Hi,
Trying to follow this discussion, I opened Chris's [named-arguments-help.pd] and got these error messages from Pd-Extended 0.44:
list fromsymbol: unknown function list fromsymbol ... couldn't create list tosymbol: unknown function list tosymbol ... couldn't create
Can you use those arguments to [list]? How?
Those subclasses have been introduced very recently (0.46?) into Pd.
Roman
Hi Katja,
On 24/10/14 16:15, katja wrote:
list fromsymbol: unknown function list tosymbol: unknown function
Can you use those arguments to [list]? How?
Only since Pd 0.46.
Cheers,
Chris.
On Thu, 2014-10-23 at 21:47 -0700, Jonathan Wilkes via Pd-list wrote:
I think we're talking about the same thing.
In matju's scheme, the abstraction author can make it possible for a user to type something like this: [myabstraction, something 1 2 3, something_else blah]
After the objects inside myabstraction are instantiated, it would output this from the leftmost inlet inside the abstraction: something 1 2 3 something_else blah
Then the abstraction author can [route something something_else] in order to use those messages to initialize whatever they want inside the abstraction. I assume this is what would happen in your scheme after the final [route bang] to the outlet at the end of the patch.
In fact you can do this in Pd Vanilla and obviate the symbol parsing/conversion. Try this: [named-arguments foo bar, height 12, cats miaow look ma an arbitrary number of values for this last named "arg"]
Break the list into sequences using [sel,]. It works because Pd's parser converts the comma atoms to symbols consisting of an escaped comma.
Quite a few times, I wished so much something like this would be possible and I didn't even bother to try assuming that something like 'cat meow, hund wau' would be split into 'cat' 'meow,' 'hund' 'wua'. But as you fortunately showed us, the comma is split separately! That is really useful to know. Thanks a lot for bringing it up.
Roman
On Fri, 2014-10-24 at 11:28 +0800, Chris McCormick wrote:
Hi all,
Here's a design pattern for passing named arguments ("bar=true foo=12") into an abstraction.
Cool idea! Although Jonathan has point in stating the comma-separated syntax may be more Pd-ish, I still very much like the look of your proposed syntax. I'm probably gonna use it for some of my stuff (once I manage to decide to leave compatibility with 0.43 behind).
Thanks for sharing. Roman