gensym with long ?

Jun 20, 2012 at 3:14pm

gensym with long ?

Hello,

void symbolWithTag (t_symbol **s, long tag)
{
    char string[4];
    snprintf (string, 4, "%ld", tag);
    string[3] = 0;
    (*s) = gensym (string);
}

Is it safe to use such keys for a t_dictionary ? I mean “0″ “1″ “2″ etc …

It seems but i need to be 100 % sure as i try to debug an annoying intermittent bug …

Thanks.

#46159
Jun 20, 2012 at 5:57pm

Hi Nicolas.
In some old post Joshua says that the keys of a t_hashtab, although declared as t_symbol*s, are just any 32-bit values. So you can use anything you like, with the possible exception of 0 (I’m not sure, but I might have stumbled upon this someday): no need to call gensym() at all!
I think that t_dictionary is built upon t_hashtab, so in principle you can do the same…
aa

#166270
Jun 21, 2012 at 6:08am

Hello,

so i suppose t_hashtab, t_dictionary, t_quickmap use the gensym adress as value to hash ; so there is no reason for gensym(“0″) and gensym (“toto et momo”) to be treated differently … i wanted to be sure.

I use gensym (“0″) for readability after serialization. And i confirm that none of them accept 0/NULL as key ;-)

Thanks.

#166271

You must be logged in to reply to this topic.