Hi devs...
I'm thinking about finally writing a "list" object for Pd to do jobs like "append", "any", etc. I've held off so far because I've felt unsure about the best design... and once I stick it in the "base" Pd it will be hard to change.
To avoid cluttering up the namespace I want to use just the one name, "list", and use the first argument to differentiate between functions (an idea inspired by Krzysztof's xeq object). Here are the functions I imagine:
list append - append a list to another list prepend - prepend a list to another list cat - build a list by accumulating elements list serialize - spit out elements of a list one by one list first - output first n elements list last - output last n elements list length - output number of items in list list reverse - permute elements of a list back to front list pack - synonym for 'pack' list unpack - synonym for 'unpack' list selector - change selector of a list list <no args> - "prepend" the selector list to non-list messages
The "append" option would also play the role of "any" (just bang the left inlet after putting any list in the right).
All of these would expect the "list" selector at the head of messages, with the exception of plain "list"; all of them would output "list" messages except "list selector". These would work as follows:
--------------------------- list ---------------------------------- in (real message) in (as printed) out (real message) out (as printed) list bang (same) list 1 1 (same) list foo list foo (same) foo foo list foo list foo
--------------------------- list selector bar ------------------------- in (real message) in (as printed) out (real message) out (as printed) list bang bar list 1 1 bar 1 list foo list foo bar foo foo foo (error)
There's one inconvenience with plain "list" since you can't differentiate "list foo" from "foo" using its output; you'd have to use "route list symbol" first and then do whatever you wanted to do differently ("list list foo" for example). It seemed better to leave that to the imagination of programmers, since there seem to be disagreements about it...
cheers Miller