unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Burton Samograd <burton@samograd.ca>
To: emacs-devel@gnu.org
Subject: Re: RFC: rough draft of Python-style generators for elisp
Date: Tue, 27 Nov 2012 08:31:29 -0700	[thread overview]
Message-ID: <kghr4nfrrji.fsf@CDW764-BURTONS.QFTI.COM> (raw)
In-Reply-To: 50B4309C.5000109@dancol.org

Daniel Colascione <dancol@dancol.org> 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 (emacs-version))"

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

--
Burton Samograd




  reply	other threads:[~2012-11-27 15:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27  3:16 RFC: rough draft of Python-style generators for elisp Daniel Colascione
2012-11-27 15:31 ` Burton Samograd [this message]
2012-11-27 21:24   ` Daniel Colascione
2012-11-27 21:26   ` Daniel Colascione
2012-11-29  8:41     ` Levin Du
2012-11-29 18:49       ` Daniel Colascione
2012-11-29 19:47         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kghr4nfrrji.fsf@CDW764-BURTONS.QFTI.COM \
    --to=burton@samograd.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).