[PD-dev] how to look up whether a symbol already exists?

zmoelnig at iem.at zmoelnig at iem.at
Sat Nov 24 10:32:05 CET 2007


Quoting Hans-Christoph Steiner <hans at eds.org>:

>
> Is there anyway to check whether a symbol already exists?

i don't know of any.


2 suggestions:
a) a symbol is a pointer
if you get a symbol as "t_symbol*s" and s!=NULL, then you can safely  
assume that the symbol already exists (except someone evil sent you  
garbage)
so you can implement:
int symbol_exists(t_symbol*s) { return (0!=s); }

b) you can always make sure, that a certain string is always  
represented as a symbol; which guarantees that your symbol exists.
int symbol_exists(char*string) { gensym(string); return 1; }


in practice, i think both implementations are rather a joke.
what do you need this for?


finally, you can bind a "class" to a symbol and lookup the class by it's name.


fma.dsr
IOhannes




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.






More information about the Pd-dev mailing list