[PD] Concatenating two atoms into one?

IOhannes m zmoelnig zmoelnig at iem.at
Thu Oct 1 10:52:46 CEST 2020


On 2020-10-01 10:10, Matt Davey wrote:
> if you bang the 7 17 message, and then bang the message box that gets set,
> pd outputs to console:
> 
> float: no method for '717'
> 
> But if you then save the patch, reload, and bang that same message box, it
> outputs correctly.
> 
> Is that a bug?  Surely if behaviour is different between a live patch and a
> saved patch, that constitutes buggy behaviour?

no. not really.

- Pd has a strong distinction between numbers and symbols.
- however, Pd displays symbols and numbers the same. (there's no
*visual* clue that a text is a number or a symbol apart from it's
content). this is why you think that your "7"+"17" is a number in the
first place.
- when Pd parses a string into an atombuffer (this is what happens when
you load a patch), it will try to determine whether a given string is a
number of not. if it looks like a number, it will become a number. if it
doesn't, it will become a symbol. this is why 717 becomes a number after
loading.

so what you are seeing is a side-effect of how Pd works - which in turn
makes Pd able to get anything accomplished in a way that makes it usable
as a live system for playing on stage.
there are languages that don't make a distinction between numbers and
strings (like PHP). there's probably a reason why people don't use PHP
for realtime signal processing; and the automatic type coercion
(treating strings as numbers and vice versa, depending on the context),
is a source of much headache and bugs.

of course, one could tweak the fileformat a little bit, so that it will
indicate that "717" is really a symbol, and when you load the patch, it
will still look like a number, but still be a symbol (so you get the "no
method for '717'" again).

the problem with this is, that it will probably break a lot of patches.


> 
>> matt's  `[set $1$2, bang(` construct is really only useful if you want
> to send the data to a messagebox (but why would you want to do that?)
> 
> I often use [set $1, bang ( for things like setting a message box with the
> output of openpanel, and then also triggering the message.  Had no idea
> that it didn't work for floats.
it works fine. why would it not?

what you are doing with [set $1, bang( is:
- store the current value for later use
- show the current value
- use the current value right now

i'm also using this quite often.
however, my "why would you want to do that" was meant to say: this
doesn't do anything useful in the context of the question.

also note that "$1" and "$1$2" are two very different things.

fgmadrs
IOhannes




More information about the Pd-list mailing list