[Top][All Lists]

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

Re: RFC: rough draft of Python-style generators for elisp

From: Burton Samograd
Subject: Re: RFC: rough draft of Python-style generators for elisp
Date: Tue, 27 Nov 2012 08:31:29 -0700
User-agent: Gnus/5.1299999999999999 (Gnus v5.13) Emacs/24.2.90 (cygwin)

Daniel Colascione <address@hidden> writes:

> Over at https://github.com/dcolascione/elisp-generators, I have a
> pure-elisp implementation of Python-style generators for elisp.
> Perhaps the feature is best illustrate by example:
> (defgenerator mygen (i)
>   (yield 1)
>   (yield i)
>   (yield 3))
> (let ((gen (mygen 100)))
>   (list  (funcall gen)
>          (funcall gen)
>          (funcall gen)))
> -> (1 100 3)
> Yields can appear in arbitrary code:
> (defgenerator mygen2 (lim)
>   (loop for x from 0 to lim do (yield x)))
> The package works by rewriting elisp into continuation-passing form
> and closing over the resulting continuations with a driver loop that
> transitions from one continuation-state to the next. After the last
> yield, the facility signals generator-ended.
> Please take a look. It'd be nice if there were cl-loop extensions to
> iterate over the things, and if generators were available with regular
> defun the way yield is available with regular "def" in Python.

When I try and byte-compile your package I get the following:

~/src/emacs-git/lisp/emacs-lisp/generators $ emacs -q --batch --eval 
"(byte-compile-file \"generator.el\")"
... <some gensym warnings> ...
generator.el:244:1:Warning: Argument "%s not supported in generators" is not a 
lexical variable
generator.el:244:1:Warning: Unused lexical argument `defvar'
generator.el:244:1:Warning: Unused lexical argument `error'
generator.el:244:1:Error: Invalid lambda variable %s not supported in generators

~/src/emacs-git/lisp/emacs-lisp/generators $ emacs --batch --eval "(print 

"GNU Emacs (i686-pc-cygwin, X toolkit, Xaw3d scroll bars)
 of 2012-11-27 on CDW764-BURTONS"

Burton Samograd

reply via email to

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