[PD-dev] how to look up whether a symbol already exists?
Hans-Christoph Steiner
hans at eds.org
Sat Nov 24 17:08:35 CET 2007
On Nov 24, 2007, at 4:32 AM, zmoelnig at iem.at wrote:
> 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.
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 at 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
More information about the Pd-dev
mailing list