[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replacement for Common Lisp's GENSYM in Emacs Lisp
From: |
Stefan Monnier |
Subject: |
Re: Replacement for Common Lisp's GENSYM in Emacs Lisp |
Date: |
Tue, 04 May 2010 15:41:58 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.93 (gnu/linux) |
>> Nothing, but luckily it doesn't make any difference whether they are
>> or not.
> Your "dotimes" macro produces:
> (let ((list '(1)) (result ()))
> (dotimes (i '(1 2 3)) (push list result))
> result) => ((3) (2 3) (1 2 3))
> While a version which doesn't shadow "list" produces this:
> (let ((list '(1)) (result ()))
> (dolist (i '(1 2 3)) (push list result))
> result) => ((1) (1) (1))
Because you're trying it out in Elisp (which uses dynamic scoping),
whereas this technique relies on lexical-scoping.
Stefan
Re: Replacement for Common Lisp's GENSYM in Emacs Lisp, Pascal J. Bourguignon, 2010/05/04