[PD] "anythings" vs. "lists" (again)
mpuckett at man104-1.ucsd.edu
Sun Jun 17 06:52:52 CEST 2001
Hi Larry, and thank you for being persistent...
This is not your misunderstanding, it's just a plain old-fashioned bug in
pd! In m_class.c, replace pd_defaultlist by the following, better
commented and bugfixed version:
/* handle "list" messages to Pds without explicit list methods defined. */
static void pd_defaultlist(t_pd *x, t_symbol *s, int argc, t_atom *argv)
/* if the object is patchable (i.e., can have proper inlets) and if
indeed it has at least one such, send it on to obj_list. */
if ((*x)->c_patchable && ((t_object *)x)->ob_inlet)
obj_list((t_object *)x, s, argc, argv);
/* a list with one element which is a number can be handled by a
"float" method if any is defined; same for "symbol". */
else if (argc == 1 && argv->a_type == A_FLOAT &&
*(*x)->c_floatmethod != pd_defaultfloat)
else if (argc == 1 && argv->a_type == A_SYMBOL &&
*(*x)->c_symbolmethod != pd_defaultsymbol)
/* nothing matched, so revert to "anything" method. */
(*(*x)->c_anymethod)(x, &s_list, argc, argv);
and then test with this "through" object:
/* through -- copy incoming messages to outlet. */
static t_class *through_class;
typedef struct _through
static void *through_new(void)
t_through *x = (t_through *)pd_new(through_class);
x->x_outlet = outlet_new(&x->x_obj, gensym("float"));
static void through_anything(t_through *x, t_symbol *s, int argc,
post("argc2 %d", argc);
outlet_anything(x->x_outlet, s, argc, argv);
through_class = class_new(gensym("through"), (t_newmethod)through_new,
0, sizeof(t_through), 0, 0);
I'm just grinding out a release in which I'll put the new code.
On Sat, Jun 16, 2001 at 07:43:33PM -0400, Larry Troxler wrote:
> Greetings again to the PD list.
> I'm sorry to report that I think I am still "not getting it" regarding
> the concept of "messages", "lists", and "anythings".
> I am running into this confusion in the course of making an object that
> calls into "Scheme In On Day". Eliminating lots of details, let's say I
> want to create an object that simply echoes its inlet to its outlet,
> whatever types they may be.
> I am using class_addanything to handle messages at the (first) inlet. If
> I send a message [a 1 2], for example, then the argv is the atoms "a",
> "1", and "2". But if I send [10 20], argv are "float" and "10". So it
> seems in this case the "20" is dropped. But yet I know it is possible
> for an object to correctly receive a message like this, because [print]
> and [line~] handle this case ok.
> I suspect that using class_addanything might not be enough, and I need
> also a class_addlist and possibly other handlers (in which case
> "addanything" might be innapropriately named?), but I'm afraid I'm still
> in the dark as to how this all works.
> I humbly suspect that probably the answer would be simple if the concept
> of PD messages were better described somewhere. The PD code is fairly
> well commented, but I find it difficult to put the pieces of the puzzle
> together into the big picture.
> I think it would be very instructive to have an example object in the
> distribution that simply echoes its input to its output. Can someone
> point me in this direction perhaps? If I get enough information, then as
> payment I will gladly code up such an object an post it.
> Best Regards,
> Larry Troxler
More information about the Pd-list