Rory Walsh wrote:
Thanks IOhannes. I'll be happy soon I feel. If I understand correctly, by changing the names of the GUI's receive symbol to $0-tgl-1 and then using that symbol of '$0-tgl-1' as a send everything should be hunky-dory? I'm afraid it's still not working as I expect, I get a load of "error: 0-tgl-1: no such object" whenever I try to send a message with that symbol. I've attached an updated abstraction. If I can get this to work its going to really simplify my crazy abstraction.
you are violating the 3rd rule of $-expansion: "there is no $0 in message-boxes".
furthermore: why do you need to _send_ things like color? just connecting the color message to the [bng] would be so much easier.
fgmasdr IOhannes
On Fri, Feb 06, 2009 at 10:51:38AM +0100, IOhannes m zmoelnig wrote:
Rory Walsh wrote:
Thanks IOhannes. I'll be happy soon I feel. If I understand correctly, by changing the names of the GUI's receive symbol to $0-tgl-1 and then using that symbol of '$0-tgl-1' as a send everything should be hunky-dory? I'm afraid it's still not working as I expect, I get a load of "error: 0-tgl-1: no such object" whenever I try to send a message with that symbol. I've attached an updated abstraction. If I can get this to work its going to really simplify my crazy abstraction.
you are violating the 3rd rule of $-expansion: "there is no $0 in message-boxes".
Just to be a bit more verbose than IOhannes: if you need to get a $0 into a message box, you need to use $1 and a regular object box with $0 before it like this:
[bang( | [$0] | [$1-hello my message(
Best,
Chris.
hi,
can somebody explain why there is a "3rd rule of $-expansion: 'there is no $0 in message-boxes'". i stumble every now and then about it and it is IMHO not self-explanatory. it is not hard to implement and wouldn't make problems with existing patches - because $0 is never used in messages. and would make things easier not only for beginners. just my 2 cents. georg
Chris McCormick schrieb:
On Fri, Feb 06, 2009 at 10:51:38AM +0100, IOhannes m zmoelnig wrote:
Rory Walsh wrote:
Thanks IOhannes. I'll be happy soon I feel. If I understand correctly, by changing the names of the GUI's receive symbol to $0-tgl-1 and then using that symbol of '$0-tgl-1' as a send everything should be hunky-dory? I'm afraid it's still not working as I expect, I get a load of "error: 0-tgl-1: no such object" whenever I try to send a message with that symbol. I've attached an updated abstraction. If I can get this to work its going to really simplify my crazy abstraction.
you are violating the 3rd rule of $-expansion: "there is no $0 in message-boxes".
Just to be a bit more verbose than IOhannes: if you need to get a $0 into a message box, you need to use $1 and a regular object box with $0 before it like this:
[bang( | [$0] | [$1-hello my message(
Best,
Chris.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Georg Werner wrote:
hi,
Hi Georg,
can somebody explain why there is a "3rd rule of $-expansion: 'there is no $0 in message-boxes'".
The following is from an implementor's viewpoint, not a user's viewpoint, so be warned :)
I don't know why, but it makes parsing Pd patches 1000x less straightforward than required (you need a two-phase parser that has a special exception to detect message boxes and not expand dollars, allowing the message box objects to parse them itself later, while expanding dollars for everything else).
I ran into this problem implementing PotatoData (basically a proof of concept, it's a Pd patch interpreter written in Lua with minimal amounts of C for DSP, can run some trivial audio patches) a couple of months ago, and just ducked it completely - message boxes in my implementation don't support dollars at all (nor commas or semicolons for sequencing and redirection, but that's a separate issue).
I wish message boxes had used a different special character, it would have made life much much easier.
i stumble every now and then about it and it is IMHO not self-explanatory.
It's a mess. There are two similar concepts at work:
But they both use the same $ symbol syntax in Pd, so you can't have both taking place (ie, use $ at patch execution to create a message box that has $ to replace at dataflow time). And $0 is in phase 1, so what should a message box do with $0 in phase 2?
The confusion arises partly because when Pd loads a patch, it's really internally passing messages around.
$ in message boxes is unfortunate. If there was a different symbol, perhaps #, you could combine both phases in one object box to avoid jumping through pointless hoops.
[$0-#1-$2-#3( would be nice, but as Pd is now, it's a nightmare.
Hi Claude,
thanks for your explanation - i got your point, but this 2-phase parser is (must have been) already implemented in Pd. So, where do you see a problem in expanding/replacing $0 in "Phase 2" - like $1 etc. (with that special fixed value)? georg
Claude Heiland-Allen schrieb:
Georg Werner wrote:
hi,
Hi Georg,
can somebody explain why there is a "3rd rule of $-expansion: 'there is no $0 in message-boxes'".
The following is from an implementor's viewpoint, not a user's viewpoint, so be warned :)
I don't know why, but it makes parsing Pd patches 1000x less straightforward than required (you need a two-phase parser that has a special exception to detect message boxes and not expand dollars, allowing the message box objects to parse them itself later, while expanding dollars for everything else).
I ran into this problem implementing PotatoData (basically a proof of concept, it's a Pd patch interpreter written in Lua with minimal amounts of C for DSP, can run some trivial audio patches) a couple of months ago, and just ducked it completely - message boxes in my implementation don't support dollars at all (nor commas or semicolons for sequencing and redirection, but that's a separate issue).
I wish message boxes had used a different special character, it would have made life much much easier.
i stumble every now and then about it and it is IMHO not self-explanatory.
It's a mess. There are two similar concepts at work:
- replacing dollars with arguments at patch execution time
- replacing dollars with arguments at message passing time
But they both use the same $ symbol syntax in Pd, so you can't have both taking place (ie, use $ at patch execution to create a message box that has $ to replace at dataflow time). And $0 is in phase 1, so what should a message box do with $0 in phase 2?
The confusion arises partly because when Pd loads a patch, it's really internally passing messages around.
$ in message boxes is unfortunate. If there was a different symbol, perhaps #, you could combine both phases in one object box to avoid jumping through pointless hoops.
[$0-#1-$2-#3( would be nice, but as Pd is now, it's a nightmare.
Claude
On Sat, 7 Feb 2009, Claude Heiland-Allen wrote:
I don't know why, but it makes parsing Pd patches 1000x less straightforward than required (you need a two-phase parser that has a special exception to detect message boxes and not expand dollars, allowing the message box objects to parse them itself later, while expanding dollars for everything else).
The way it works in Pd, Is that the parsing only cuts a patch into lists of atoms, and then the evaluation of $ is a separate phase. There are two levels of evaluation of $ in patches: one is because the patch is saved as a sequence of messages that do dynamic patching of all of the patch. Therefore, an objectbox containing $0 has to be saved as $0, which gets converted to $0 on the first evaluation, and the $0 turns into a float on the second evaluation.
I don't think that this way of doing things is really bad, except perhaps that it allows one to make patches that do weird things that don't get saved back the same way (e.g. what if you edit a .pd file to put non-backslashed dollars in it?)
That #X obj has this extra evaluation level compared to #X msg and others, is not necessarily bad nor uncommon. The LISP languages generally have that: there are a number of so-called special-forms in which arguments are not evaluated, and some others in which only some arguments are evaluated. This is how 'foo is a shortcut for (quote foo) in which the argument of quote is not evaluated. In theory, you only really need that one special-form in such a language, but the inventors of this figured out that it was annoying to have to have only one special-form because it needs too many apostrophes all over the place. In the end, though, inventors of various LISP dialects could not agree on how many special-forms there should be. (Macros allow the user to define its own things that look like special-forms, but because of their evaluation order, it also allows bypassing any non-evaluation too)
In Tcl, which is a distant cousin of LISP, things are different. Instead, there is an extra level of syntax because all lists are assumed to be quoted, a first parsing handles only { } { } and a second parsing handles $ $ [ ] [ ] ... not counting the [expr] calls, which are a third level of parsing and happens quite often because it's explicit in [if] [while] etc. The avoidance of having some kind of evaluation at the first level of parsing makes it necessary to have the second level. My point is that it's a tradeoff in the design of languages. If you remove complexity in one way, it reappears in another way if the complexity is necessary.
So, what could have Pd done differently? Perhaps two things:
backslashes aren't needed in the file format.
message arguments are substituted using # or whatever (that's a second level of parsing because # is not recognised at the first parsing level; or would it??). But this makes people want to use $ to access abstraction-args directly in it, and if that feature is considered as a good thing, then you still need to either skip substitution in #X msg by opposition to #X obj, or add another level of backslashes in msg.
(But that's all very hypothetical and nothing of that will change in pd)
I ran into this problem implementing PotatoData (basically a proof of concept, it's a Pd patch interpreter written in Lua with minimal amounts of C for DSP, can run some trivial audio patches) a couple of months ago, and just ducked it completely - message boxes in my implementation don't support dollars at all (nor commas or semicolons for sequencing and redirection, but that's a separate issue). I wish message boxes had used a different special character, it would have made life much much easier.
I don't think it's a big deal. There are much more difficult things than that, that you have to do to make a good interpreter and/or compiler. It's just a bit confusing and somewhat easy to get wrong if you don't put all of your attention in it, but if pd were different, this set of problems would be replaced by another set of problems.
It's a mess. There are two similar concepts at work:
- replacing dollars with arguments at patch execution time
- replacing dollars with arguments at message passing time
There are three of them. 0. replacing dollars when loading patch (not normally used)
The confusion arises partly because when Pd loads a patch, it's really internally passing messages around.
That's why level 0 is there. It's never used by normal patches, yet it makes it necessary to add extra backslashes everywhere.
Perhaps all this Pd parsing process is more difficult because it is not so well documented (or the documentation has been forgotten in some dungeon and is not part of any manual). Therefore you have to discover more of it yourself and may have surprises and there are not many people paying attention to the topic and not much standard terminology to talk about how it is done in Pd. It doesn't *have* to be simplified, it has to be seen as simpler. But in any case, things become seen as simpler once they are understood.
$ in message boxes is unfortunate. If there was a different symbol, perhaps #, you could combine both phases in one object box to avoid jumping through pointless hoops.
exactly. well, it's very well possible to just avoid using messageboxes and instead use an external that would do the same job. It's not so hard.
[$0-#1-$2-#3( would be nice, but as Pd is now, it's a nightmare.
What about [m $0-#1-$2-#3] ? if such an external existed... the only funky thing in there is if $2 substitutes to something with a "#" in it... in that case, the extra level of evaluation would become apparent.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec
Hallo, Georg Werner hat gesagt: // Georg Werner wrote:
can somebody explain why there is a "3rd rule of $-expansion: 'there is no $0 in message-boxes'". i stumble every now and then about it and it is IMHO not self-explanatory. it is not hard to implement and wouldn't make problems with existing patches - because $0 is never used in messages. and would make things easier not only for beginners.
Actually this topic is discussed about once or twice a year on pd-list and pd-dev, so for deeper info check the archive.
Anyway: $0 is a property of the surrounding abstraction or canvas, as are $1,... in object arguments. The $1,... in message boxes however are properties of the messages sent around and reaching a message box. While the value of dollar variable in message boxes changes all the time, the value of the canvas-dollars never change.
Messages don't have anything comparable to the canvas' $0.
A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Frank Barknecht Do You RjDj.me? _ ______footils.org__
On Sat, 7 Feb 2009, Frank Barknecht wrote:
Messages don't have anything comparable to the canvas' $0. A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Why would that be confusing to beginners?
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec
Hallo, Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:
On Sat, 7 Feb 2009, Frank Barknecht wrote:
Messages don't have anything comparable to the canvas' $0. A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Why would that be confusing to beginners?
Because it's not the $0 from object boxes.
Frank
On Tue, 10 Feb 2009, Frank Barknecht wrote:
Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:
On Sat, 7 Feb 2009, Frank Barknecht wrote:
Messages don't have anything comparable to the canvas' $0. A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Why would that be confusing to beginners?
Because it's not the $0 from object boxes.
Ok. That was my impression too. As Johannes was saying, $0 in objectboxes could have been referring to the name of the abstraction (as it was located in the first place). That would have made it much more sensible to have that $0 in messageboxes.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec
Frank Barknecht wrote:
Hallo, Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:
On Sat, 7 Feb 2009, Frank Barknecht wrote:
Messages don't have anything comparable to the canvas' $0.
I missed this the first time it went by, and I think it's central to (my) confusion about this...
Messages don't have anything comparable to the canvas' $0, but *message boxes do*! Why, therefore, is $0 not valid in a message box (as a way of embedding the canvas-identifier into a message), and further, why are people going so far as to suggest new, orthogonal meanings for $0 in a message box? Please, don't do this; it would only make the situation much more confusing!
Arrgh!
Phil
A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Why would that be confusing to beginners?
Because it's not the $0 from object boxes.
Ciao
There is already [route] to get the selectors bang, symbol, list,
float and only 'other'. But it would be nice to have something like
this :
[33 hello -4.5 world( | [$0( | [print]
and get print: list not 0 as now
or
[open mytext.txt 45( | [$0( | [print]
and get print: open not 0 as now (and nor 'other' as does [route])
So the first element is $0, the second is $1, etc.
I think it is not so difficult to understand for a beginner because
it's logical.
We must explain that [33 hello 4.5 world( is a list without the word
list in the message because the message begin by a number and has
several elements : it is the same [list 33 hello 4.5 world(. Idem for
float.
What do you think ?
++
Jack
Le 10 févr. 09 à 17:45, Mathieu Bouchard a écrit :
On Sat, 7 Feb 2009, Frank Barknecht wrote:
Messages don't have anything comparable to the canvas' $0. A possible alternative use for $0 in messages would be the selector ("list", "symbol", ...) as that is the thing before $1, but implementing that could be even more confusing to beginners.
Why would that be confusing to beginners?
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal,
Québec_______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Jack wrote:
What do you think ?
s this is basically what frank has been suggesting and what matju and me have kind-of supported. it would have been good if it was like that in the first place.
the rest frank, matju and me have written about it is, that it would be a bad idea to add this to Pd as it is now. it would make $0 be even more complicated to understand.
mfgads.r IOhanne
PS: apologies to frank and matju if they do not agree and i made them look like