[PD-dev] class_addmethod2

Hans-Christoph Steiner hans at eds.org
Fri Dec 16 00:55:23 CET 2005


I have to say that I like the A_FLOAT, etc names better (you can  
probably guess why).  Code should document itself.  "pffsFFS" is easy  
to skim over while "A_POINTER, A_FLOAT, A_FLOAT, A_SYMBOL, A_DEFFLOAT,  
A_DEFFLOAT, A_DEFSYMBOL" is very clear.   I won't miss the A_NULL  
though.

This function is only used once per object, and it defines the  
structure of the object, so it should be as clear as possible.  The  
A_FLOAT style of function is very commonly used throughout C libraries,  
so it makes sense.

.hc

On Dec 15, 2005, at 12:49 PM, Miller Puckette wrote:

> How about calling this "class_addv" or, possibly, "class_vmess"?  I  
> think
> it's a much better design than class_addmethod and I should add it,  
> once
> we figure out the best name, to the "main" API.
>
> cheers
> Miller
>
> On Sun, Nov 20, 2005 at 01:57:24PM -0500, Mathieu Bouchard wrote:
>>
>> A few days ago I added class_addmethod2 to m_class.c and m_pd.h.
>>
>> Its advantages over class_addmethod are:
>>
>>   1. it doesn't use varargs and you don't need to remember to use  
>> A_NULL
>>   2. the syntax is shorter so declarations can fit in one line
>>   3. it's closer to how binbuf_addv works
>>
>> basically, atom types are given letters:
>>
>> f=A_FLOAT   F=A_DEFFLOAT
>> s=A_SYMBOL  S=A_DEFSYMBOL
>> p=A_POINTER
>> *=A_GIMME
>> !=A_CANT  (e.g. for dsp messages)
>>
>> so instead of writing:
>>
>>   class_addmethod(myclass, (t_method)myclass_mymethod,  
>> gensym("mymethod"),
>>     A_POINTER, A_FLOAT, A_FLOAT, A_SYMBOL, A_DEFFLOAT, A_DEFFLOAT,
>>     A_DEFSYMBOL, A_NULL);
>>
>> you can write:
>>
>>   class_addmethod2(myclass, (t_method)myclass_mymethod,  
>> gensym("mymethod"),
>>     "pffsFFS");
>>
>> and class_addmethod3 is a macro in desire.c which further abbreviates  
>> it:
>>
>>   class_addmethod3(myclass, myclass_mymethod, "mymethod", "pffsFFS");
>>
>> ____________________________________________________________________
>> Mathieu Bouchard - t?l:+1.514.383.3801 - http://artengine.ca/matju
>> Freelance Digital Arts Engineer, Montr?al QC Canada
>>
>> _______________________________________________
>> PD-dev mailing list
>> PD-dev at iem.at
>> http://lists.puredata.info/listinfo/pd-dev
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev
>

________________________________________________________________________ 
____

"I have the audacity to believe that peoples everywhere can have three  
meals a day for their bodies, education and culture for their minds,  
and dignity, equality and freedom for their spirits."
                                             - Martin Luther King, Jr.





More information about the Pd-dev mailing list