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

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

bug#748: Elisp: lexical-let and cyclic structures


From: Stefan Monnier
Subject: bug#748: Elisp: lexical-let and cyclic structures
Date: Wed, 20 Aug 2008 21:12:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

tag +748 wontfix
thanks

> When using the reader constructs `#N=' and `#N#' for cyclic
> structures, lexical-let sometimes produces errors which don't occur
> with let.

Most programming languages do not accept infinite programs.  Elisp is
no exception.  The fact that you can build cyclic abstract syntax trees
and that they sometimes get evaluated correctly is just an accident.

I.e. if it hurts, don't do it.

> (defun f (start)
>   (lexical-let (start start)         ;; return a closure
>     #1=(lambda (x) (if (= x start) x
>                    (+ x (#1# (1- x)))))))

For this case, I'd recommend to make the recursion explicit, e.g.:

   (defun f (start)
     (lexical-let ((start start))         ;; return a closure
       (labels ((loop (x) (if (= x start) x
                           (+ x (loop (1- x))))))
         loop)))


-- Stefan






reply via email to

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