[plt-scheme] Unique interned symbols

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Fri Dec 15 08:13:45 EST 2006

Dear All,

Is there a recommended way of generating unique interned symbols?

I'm auto-generating HTML inputs. I want to allow the programmer to  
specify an ID for an input if they want, but auto-generate one if  
they don't really care about the HTML implementation. Currently I'm  
using something like:

     (define id
       (if user-specified-id
           (string->symbol (symbol->string (gensym '--input)))))

Aside from this obvious bit of dodginess, I'm not sure whether using  
gensym like this is a "bad idea". Is there a better mechanism for  
this kind of thing built into PLT, or should I be writing some kind  
of ID management code?

(The double-dash prefix is a half-hearted attempt to get around one  
problem: what if a programmer manually picks an auto-generated  

-- Dave

Posted on the users mailing list.