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

GENSYM/GENTEMP/GENLOCAL



-----
RWK@MIT-MC 09/02/81 02:53:18 Re: GENLOCAL
To: MOON at MIT-MC
CC: LISP-FORM at MIT-MC
You have inadvertently hit the thumb square on the nail.  The purpose of
GENLOCAL primarily to have an uninterned symbol so you can avoid all sorts of
problems.  Indeed, I can't imagine any reason this functionality couldn't be
given to GENSYM.  The main improvement of GENLOCAL over GENSYM is the
preservation of this important property when the symbol is written into a
FASL/VASL/QFASL file and loaded back in again.  A normal GENSYM written to a
FASL file and read back in will be interned.  Thus, if you save a code-
fragment with a gensym (say, describing a structure reference) into a file, and
later do the same with another file, there is a certain small but real
probability that the two gensyms will have the same pname.  If so, they may
conflict with each other when you load the two files.  I have seen exactly that
happen a number of times.

As I view it, this is just a better fulfilment of GENSYM's contract.  Others
might reasonbly argue that this is incompatible with GENSYM, I suppose.

The bit about generating unique names is primarily an extention of the above
argument to include uniqueness across print-into-file/read and other situations
where INTERN is the only uniqification being done, unlike FASL files where a
symbol is output only once.

Of course, uniqueness of ex-gensyms is more important when your compiler
has problems with nested declarations, so this problem was discovered in
MACLISP first, but it can happen in any system.

Another feature of GENLOCAL is that it takes an argument which is taken to
provide the initial part of the generated symbol, to help readability of
the result.  I.e. (GENLOCAL "BODY") ==> BODY..259 .  This is rather
incompatible with the old definition of GENSYM, and far more useful.

I never call GENSYM anymore, and can't see how changing GENSYM to be like
GENLOCAL would screw anyone.  But with any feature this old you never know
what people may depend on.

For those confused by prior discussion, the difference between GENTEMP and
GENLOCAL is trivial.  GENLOCAL in MacLisp would also arrange to inhibit the
(DECLARE (SYMBOLS T)) switch in MACLISP, which is defined to auto-specialize
all user-variables.  Thus GENLOCAL's symbols will not be autospecialized.
This is almost certainly irrelevent for other dialects.