[Top][All Lists]

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

Re: Declaring a local dynamic variable?

From: Stefan Monnier
Subject: Re: Declaring a local dynamic variable?
Date: Tue, 24 Sep 2013 17:40:41 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> CL has the (declare (special var…)) declaration for that.

And cl.el does provide some support for it, indeed.

> (defun f ()
>   (declare (special var))
>   (print var))

Since Elisp's `defun' macro also supports `declare', we could provide
support for the above, tho you can just as well write it as

   (defun f ()
     (defvar var)
     (print var))

>   (let ((var 42))
>      (declare (special var))
>      (f)))

Supporting for byte-compiled files would be fairly easy, but when
interpreting code it it would be very costly, so Elisp does not
support this.  With Emacs-24.3's eager macro-expansion the cost would be
a lot more reasonable, but I still don't find it worth the trouble.

Instead you have to write:

   (defvar var)
   (let ((var 42))

-- Stefan

reply via email to

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