emacs-devel
[Top][All Lists]
Advanced

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

Re: Generators (iterators) for Gnu Emacs


From: Michael Heerdegen
Subject: Re: Generators (iterators) for Gnu Emacs
Date: Fri, 05 Dec 2014 20:06:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> > Yes, that had been the intention. To make it work with dynamic callers,
> > I would have to defvar the uninterned symbol.
>
> Not only that, you'd have to build the lambda at run-time (i.e. make
> the closures "by hand").

Would this version fix the issue?

--8<---------------cut here---------------start------------->8---
(defmacro gen-make (&rest body)
  `(gen-make-1 (lambda () ,@body)))

(defun gen-make-1 (fun)
  (let (this-element)
    (lambda ()
      (if (eq this-element 'gen-done)
          'gen-done
        (setq this-element (funcall fun))))))
--8<---------------cut here---------------end--------------->8---

Though, this `gen-make' is still inferior without lexical binding, but
at least should avoid the error.

Michael.




reply via email to

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