Hey all
After watching "Future Pd Developments" round-table (thanks to everyone involved for the effort to record/put online), I feel like poking some more into the structured list idea. Some of the conclusions that came up:
* Something like [list args] as a way to get all given arguments as a list would be utterly helpful.
* Many data structures like nested lists or hashes can actually be implemented without changing the core of Pd.
I agree and I'm totally looking forward to a [list args]. Now, here comes the thing. Let's say I want to make a wrapper abstraction around [oscformat] and my wrapper abstraction takes an arbitrary number of arguments. What I'm looking for is a way to define which part of the argument list is part of an OSC address and should be passed as arguments to [oscformat] and which part should be used to set some defaults in my wrapper abstraction.
Example:
[myOSCmodule { dog cat food } { foo 123 }]
inside this:
[oscformat $1] <- would be instantiated as [oscformat dog cat food]
[loadbang] | [list append $2] <- would return 'list foo 123'
As far as I can see it, it is currently impossible to pass a variable number of arguments to child objects and also [list args] wouldn't address that. The simplest case of passing all arguments to a child object could be covered with something like a '$@', but really cool would be a way to define which arguments specifically should be passed to child objects. That's why I came up with the idea of nesting lists. Actually, I'm interested in a more sophisticated mechanism for argument inheritance.
Comments?
Roman
On Mon, 2016-10-31 at 13:53 +0100, Roman Haefeli wrote:
How can Pure Data's capabilities for dealing with different data sets be extended? Does it make sense to adopt concepts from scripted languages to the dataflow paradigm? Examples: tuples, dictionaries, multi-dimensional arrays, [...]
PROPOSAL: Syntax for nesting lists so that lists can be organized in a hierarchical manner and sublists (as opposed to only atoms) can be access with dollargs.
Reserved symbol atoms '{' and '}' could be used to enclose sublists (Since those characters are forbidden now, introduction wouldn't break anything).
An example nested list containing two sublists:
'list { a b c } { 1 2 3 }'
The third element of the the first list would be accessed like this:
[list $1( <- returns 'list a b c'
[list $3( <- returns 'symbol c'
Dollargs would strip the encompassing curly braces and return only the content of the specified sublist:
[list $2( <- returns 'list 1 2 3'
To extract the second sublist without losing its encapsulation, one would use:
[list { $2 }( <- returns 'list { 1 2 3 }'
The same syntax can be used for dollargs used in arguments. This allows to pass a whole list or even a list of lists through a single dollarg:
[myabstraction { animal mammal cat }]
and inside this abstraction, we have:
[oscformat $1 miau] <- instantiates [oscformat animal mammal cat miau]
Whether to use curly braces or something different as list markup and whether to separate markup symbols with spaces or not is to be discussed. Also, the feasibility to implement the proposed idea would be an important discussion point, since the proposer only considered a user point-of-view.