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

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

bug#15139: 24.3; Error in section 11.9.3 of the Elisp Reference Manual


From: Thierry Volpiatto
Subject: bug#15139: 24.3; Error in section 11.9.3 of the Elisp Reference Manual
Date: Tue, 20 Aug 2013 13:08:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Sian Mountbatten <poenikatu@fastmail.co.uk> writes:

> In section 11.9.3 Lexical Binding of the Elisp Reference Manual, the
> following forms are given:
>
> (defvar my-ticker nil)  ; comment
>
> (let ((x 0))
>      (setq my-ticker (lambda ()
>                        (setq x (1+ x)))))
>
> (funcall my-ticker)
>
> The manual says that the 3rd form (funcall...) yields `1'. When these
> forms are evaluated using C-xC-e, the 3rd form enters the debugger with
> the error `void variable x'.

The manual is speaking of lexical binding, try this or use the code
above in a lexical-binding environment:

(defvar my-ticker nil)  ; comment

(lexical-let ((x 0))
  (setq my-ticker (lambda ()
                    (setq x (1+ x)))))

(funcall my-ticker)

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






reply via email to

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