[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is a compiler (vol. 63827) meets what are gensyms.

    Date: Tue, 22 Apr 86 10:47  EST
    From: Daniel L. Weinreb <DLW at SCRC-QUABBIN.ARPA>

    For purposes of the archives, though, I'd like to point out that if we
    try to define this formally in the manual, we had better be careful.
    Consider what happens if you run the dumper twice, creating two
    independent files, and each run contains a certain uninterned symbol.
    Then, in a new Lisp world, you load both files.  If you require the
    dumper to maintain EQness in this case, the dumper will be extremely
    difficult to implement correctly.  In fact, the same issues apply to
    objects other than uninterned symbols, such as conses.

Also just for the archives:  all these problems with EQness of gensyms
and locations could be solved if Common Lisp had a way to generate truly
unique names.  The Aegis operating system has this feature, and it's
incredibly powerful:  a "generate UID" system call will give you a bit
string (64 bits long) which is different from any other UID created at
any time by any other call to generate-UID on any machine running Aegis.
UID's are generated from the time of day and the serial number of the
CPU.  Within the operating system they're used mostly to identify files,
processes, types, and other objects, but anyone is free to use them in
any circumstance which requires a unique token.

A very similar mechanism which more of you might be familiar with is the
"message id's" generated by mail systems, although I'm not aware of the
existence of any universally applied convention which really guarantees
uniqueness.  One convention that would work would be if message-id's
began with the domain name of the machine which generated the message
id.  (To make that really work, you'd have to make sure that every
machine had a domain name, and that different machines had different

I believe a mechanism like these could be adopted by a language and made
to work on arbitrary host operating systems and machines.  If the
operating system has a way to determine the CPU's serial number, the
date & time of day (precisely), and a process ID, then it's
straightforward.  (I leave out some detail that makes sure there won't
be collisions between names generated by different implementations or
machine types.)  If a machine serial number isn't available, then
guaranteeing uniqueness is more difficult, but still possible; e.g. a
serial number could be generated when Lisp is installed on a particular
CPU (or file system).

  (gensym)  =>  #:860422104731.16.9112.JAR@MC.MIT.LCS.EDU
or whatever.

Given a mechanism like this, gensyms could in fact be interned, and so
could locations of conses and other mutable objects.  Since the identity
of a gensym would be determined by its truly unique name, it could be
freely dumped and restored, or even printed and read, just like any
other symbol.

This may be a little too ambitious for Common Lisp, but I just wanted to
point out that the process of dumping and restoring gensyms is not prone
to inconsistencies, if gensyms really are unique.

(Maybe this could solve the package name collision problem, too...)