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
Hi Rolf,
Try prepending the word "list" to make it a list . I assume $1 skips the first word as an indicator (if not a number; e.g. float, symbol, list) , while [list split] automatically makes lists and symbols out of the input.
On Mon, Jan 20, 2014 at 3:34 PM, rolfm@dds.nl wrote:
output: this: two three this: two three
I think your output was just a little different:
this: two three this: list two three
It will become ...
this: one two this: list two three
... when you change your three words to a list like this:
[list one two three(
Regards, Funs
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-01-20 15:34, rolfm@dds.nl wrote:
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?
why not? what did you expect?
fgamsdr IOhannes
Le 20/01/2014 15:34, rolfm@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
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 jack@rybn.org wrote:
Le 20/01/2014 15:34, rolfm@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
Thanks Jonathan for the detailed response and pointer to the docs. As a longtime (but somewhat sporadic) PD user this list behavior still becomes a bit fuzzy to me sometimes, and this helps make it much more clear.
-s
On Mon, Jan 20, 2014 at 1:30 PM, Jonathan Wilkes jancsika@yahoo.com wrote:
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 jack@rybn.org wrote: Le 20/01/2014 15:34, rolfm@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
On 01/20/2014 02:07 PM, Spencer Russell wrote:
Thanks Jonathan for the detailed response and pointer to the docs. As a longtime (but somewhat sporadic) PD user this list behavior still becomes a bit fuzzy to me sometimes, and this helps make it much more clear.
-s
It might help some if the selector inside a message box were visually distinct from the rest of the message. Like the little tag widget in QT that's often used in email apps to show someone's nickname and hide the addy. It's basically a rounded rectangle in a pastel color around some text.
You could also have different colors for built-ins vs. custom selectors.
-Jonathan
On 01/21/2014 04:02 AM, IOhannes m zmölnig wrote:
On 01/20/2014 10:01 PM, Jonathan Wilkes wrote:
It might help some if the selector inside a message box were visually distinct from the rest of the message.
+1
You could also have different colors for built-ins vs. custom selectors.
-1
Hm... care to explain your votes? Is it the word "colors" that got a "-1", or the idea of visually distinguishing between the two groups?
-Jonathan
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 2014-01-21 22:35, Jonathan Wilkes wrote:
On 01/21/2014 04:02 AM, IOhannes m zmölnig wrote:
On 01/20/2014 10:01 PM, Jonathan Wilkes wrote:
It might help some if the selector inside a message box were visually distinct from the rest of the message.
+1
You could also have different colors for built-ins vs. custom selectors.
-1
Hm... care to explain your votes? Is it the word "colors" that got a "-1", or the idea of visually distinguishing between the two groups?
the latter.
how the selector differs from the atoms should be a matter of user-definable preferences. and i'd like to have a way to distinguish atoms (with potential whitespace characters) from the whitespace atom-separator.
fgamsdr IOhannes
On Mon, Jan 20, 2014 at 7:30 PM, Jonathan Wilkes jancsika@yahoo.com wrote:
I'm not sure why the people replying to you are feigning ignorance on how this situation could possibly be confusing.
I'm not aware of feigning or having feigned ignorance. I was just pointing out about the same as you did, although I must say that your explanation was a bit more elaborate. Where I used the word "indicator" I meant "selector" of course.
-- Funs
On 01/21/2014 11:07 AM, Funs Seelen wrote:
On Mon, Jan 20, 2014 at 7:30 PM, Jonathan Wilkes <jancsika@yahoo.com mailto:jancsika@yahoo.com> wrote:
I'm not sure why the people replying to you are feigning ignorance on how this situation could possibly be confusing.
I'm not aware of feigning or having feigned ignorance.
Sorry, I didn't see your reply there when I wrote that, just Jack's and IOhannes'. I have a hard time believing they were unable to use their knowledge of Pd to deduce with great certainty that the OP thought [one two three(----[$1 $2(----[print] would output "one two".
In fact when I looked back at rolf's ASCII art and did the data flow in my head my brain initially flashed "one two" erroneously.
-Jonathan