[PD] "popping" from - and prepending to - a generic message

Matteo Sisti Sette matteo.sistisette at email.it
Thu Feb 8 02:25:56 CET 2007


Hi all,

Is there a reasonably stright-forward way in pd-proper (I mean, without 
externals) to do either of the following two things?
1) Removing the first element of a message (NOT necessarily a list) and 
returning the rest of the message
2) Prepending a symbol or number to a message

But I mean: this must work with ANY message, without knowing its 
"composition" (whether it starts with a number or symbol, how many 
"elements" and of what type it has, etc.)

For example, let's say I get a message which is [foo 1 2 3(
Removing the first element should give me [1 2 3(
But if the message is [1 foo 3 4 5 bar( it must give me [foo 3 4 5 bar(
and so on.

I will omit examples for the "prepend" thing :p

Solving problem 1 would indeed allow solving problem 2 (not so "stright 
forward" though:)
Not viceversa, as far as I can see.

I came up with a rather tricky solution for (1) but it involves "scripting" 
(dynamically adding and connecting objects in a canvas by sending it 
messages) and I'm finding out that PD is quite buggy when you start using 
that sort of things. When trying to use it to solve problem 2, I ended up 
with a patch that makes pd crash (but it shouldn't). However, I'm still 
trying to isolate the bug before I submit it to the bug tracker.
Furthermore, the solution to (1) alone works fine but generates some errors 
in the pd output (because I intentionally use "unpack s" and "unpack f" at 
the same time so that only one of them matches and produces output).

Which by the way raises a secondary question: is there a way to turn off/on 
error reporting?

Also I found an almost as tricky (and not elegant) solution to problem 2 
alone, without "scripting" but which requieres the message not to exceed a 
fixed maximum length (number of "elements"). And it generates "unpack 
mismatch" error messages too.

If anyone is interested I can share the mentioned patches, but first I was 
wondering if I am missing a much simpler solution.

I know there are externals that do this sort of things, but I like doing 
things natively in pd whenever I can, and this is also a speculative 
curiosity.

Thanks
M. 





More information about the Pd-list mailing list