[PD] opening patch from pd message

IOhannes m zmölnig zmoelnig at iem.at
Tue Nov 26 18:33:08 CET 2019


On 11/26/19 4:59 PM, Peter P. wrote:
> * IOhannes m zmölnig <zmoelnig at iem.at> [2019-11-26 16:03]:
>> Am 26. November 2019 15:49:07 MEZ schrieb Roman Haefeli <reduzent at gmail.com>:
>>> On Tue, 2019-11-26 at 15:12 +0100, Csaba Láng wrote:
>>>> Dear list,
>>>>
>>>> I want to open from a pd patch a pd patch withe the message:
>>>>
>>>> [;
>>>> pd open $1.pd /path-topatch;(
>>>
>>> [...]
>>>
>>>> just to be clear, if I want to open cat.pd, a message [cat( will not
>>>> make it happen.
>>>
>>> Use [symbol cat(.
>>
>>
>> and if you have many, many files (msgboxes) you can convert (almost) any selector toa symbol with [symbol]:
> 
> jumping on this I must admit that I never understood when a selector
> such as "symbol" or "list" has to be provided explicitely, or to be
> trimmed off.


# anatomy of a message

i think it is pretty easy:
- any message in pd-land consists of a single selector and any number of
atoms (including none).
- an atom can be a number, a symbol, a gpointer and "other things"
- a selector must always be a symbol.
some special selectors need a fixed number of atoms, of a fixed type
("float" and "symbol" require exactly 1 atom of the resp. type; "bang"
requires exactly 0 atoms); but these are special cases.

dollar-arguments in msgboxes (e.g. [open $1.wav() always refer to the atoms.

## implicit selectors

if you have a msgbox [foo bar 1(, then this is a message with the
selector "foo" and two atoms, a symbol "bar" and a number "1".

if you have a msgbox [1(, then the 1st element would be "1" (a number).
since messages must always start with a selector (a symbol), it cannot
start with the number "1". and Pd implicitely adds a default selector to
this message. since the msg only consists of a single number atom, the
implicitely added selector is "float".
if you have a msgbox [1 bar foo(, we also miss a (symbol) selector, but
the "float" selector requires a single atom (and our message has 3
atoms, once we add a selector), so Pd adds a "list" selector.

# why do we need selectors?

so why are messages like they are in the first place?
each object in Pd has a number of methods (functions that interact with
the internal state of the object). objects and methods are something we
know from object-oriented programming (C++, ...)
in Pd, objects communicate via messages - and communication boils down
to calling methods in other objects.
so messages need some way to encode which method of the downstream
object is being called: and this is what the selector does.
e.g. an object might have a method for messages with the "foo"-selector
and messages with the "bang" selector, but no messages with the "float"
selector.

so if you want to stop a delay, you want to call the "stop" method of
the [delay] object, thus sending a [stop( message (selector is "stop",
no atoms).

mdsar
IOhannes

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20191126/50723834/attachment-0001.sig>


More information about the Pd-list mailing list