I'm not sure why the people replying to you are feigning ignorance on how this
situation could possibly be confusing. You're chopping off the word "one" with
[list split] and leaving it intact on the other message; yet the dollarsign
substitution gives you the same output in both cases. Furthermore, if you use
[list length] on each message you will find the two message have a different
number of elements.
What you don't see, however, is that [list] objects like [list split] interpret
incoming messages as "list" messages-- that is, they add the word "list" to the
beginning of the message. Also, they prepend a "list" selector to the messages
they send out (except for [list trim], of course).
But we're not done. The selectors "list", "float", and "symbol" are special
and do not get counted as elements with [list length]. Yet inside message
boxes they _do_ get counted as the selector (i.e., the very first symbol atom
in a message) when variable substitution is involved.
Once you know those two details it gets a little easier to grasp.
This is all further complicated by the fact that there is no dollarsign
variable in Pd that can get the selector of an incoming message. So for "list
two three" you can't get "list" with a dollarsign variable, and likewise for
"one two three" you can't get "one" with a dollarsign variable. That's a real
sticking point for new users, especially because they've no doubt already seen
how seamlessly everything works when only numbers are involved.
So I'd suggest everyone have a look at the help patch for [list], especially
the subpatch labeled [pd about-lists]. In it, Miller Puckette-- the guy who
designed and implemented this part of the language-- describes what is
happening in some detail. In his explanation he questions his own design, even
going so far as calling the very distinction you point out here "ugly". It's
not the easiest part of Pd to understand, and it's the reason why you're having
a problem in the patch example you gave.
But if you learn to use the [list] family objects when dealing with data
messages it can makes things a lot easier. Since you know those objects will
output messages with a "list" selector, then for everything other than a bang
you're guaranteed that [$1( will work properly.
-Jonathan
On Monday, January 20, 2014 11:33 AM, Jack <j...@rybn.org> wrote:
Le 20/01/2014 15:34, ro...@dds.nl a écrit :
> dear list,
>
> i'm confused about the $1 replacement in messages.
>
> [one two three(
> |\
> | \
> | [list split 1]
> | /
> | /
> | /
> | /
> |
> [;
> [this $1 $2(
>
> [r this]
> |
> [print this]
>
> output:
> this: two three
> this: two three
>
> why?
>
> rolf
>
>
> _______________________________________________
> Pd-list@iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
[one two three( is not a list.
[list one two three( is a list.
So what you get is *maybe* the normal behavior ?
But, yep, what did you expect ?
++
Jack
_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list
_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list