help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Replacement for Common Lisp's GENSYM in Emacs Lisp


From: Pascal J. Bourguignon
Subject: Re: Replacement for Common Lisp's GENSYM in Emacs Lisp
Date: Tue, 04 May 2010 15:42:09 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin)

Teemu Likonen <address@hidden> writes:

> * 2010-03-07 06:48 (+0100), address@hidden wrote:
>
>> On Sat, Mar 06, 2010 at 05:19:43PM +0200, Teemu Likonen wrote:
>>> In Common Lisp GENSYM function generates unique symbol names. It
>>> seems that Emacs Lisp does not have similar function (unless with CL
>>> extension). In plain Emacs Lisp code and macros, what would you
>>> suggest as a replacement for GENSYM? Just some very unlikely names?
>>
>> It seems `make-symbol' is what you are looking for. It generates an
>> uninterned symbol. Cf. Emacs Lisp manual "13.6.3 Local Variables in
>> Macro Expansions" to find an usage example.
>
> That's right. My question was rather stupid, or at least asked too
> hastily. It was in my mental patterns that I need GENSYM to create
> symbols for macros. So I immediately thought I need to write a GENSYM
> replacement for Emacs Lisp. But as you and David pointed out, the point
> wasn't really unique print names but uninterned symbols. So make-symbol
> is often sufficient. Thanks.

Of course, (even in Common Lisp) macros could always use make-symbol.
If we use (gensym), or even better, (gensym "varname"), it's to be able
to read the expansion of macros.  It's a debugging device.

But we could also (setq print-circle t) and use (make-symbol "varname");
the #=/## notation will allow us to distinguish the different symbols
generated.


-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]