On Nov 24, 2007, at 4:32 AM, zmoelnig@iem.at wrote:
Quoting Hans-Christoph Steiner hans@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.
I was thinking if using this to check whether a libdir had loaded its associated DLL so it wouldn't be opened multiple times with dlopen (). But I think dlopen() has an associated technique to check, so I'll try that.
.hc
fma.dsr IOhannes
This message was sent using IMP, the Internet Messaging Program.
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
------------------------------------------------------------------------ ----
All mankind is of one author, and is one volume; when one man dies, one chapter is not torn out of the book, but translated into a better language; and every chapter must be so translated.... -John Donne