unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nic Ferrier <nferrier@ferrier.me.uk>
To: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: RFC: Generators v2
Date: Sun, 25 Aug 2013 09:28:19 +0100	[thread overview]
Message-ID: <87vc2uyy1o.fsf@ferrier.me.uk> (raw)
In-Reply-To: <52198EF7.50900@dancol.org> (dancol@dancol.org's message of "Sat,  24 Aug 2013 21:58:31 -0700")

dancol@dancol.org writes:

> At https://github.com/dcolascione/elisp-generators, I've updated my
> elisp generator support. Please take a look.
>
> Since the last version, I've added documentation, cl-loop
> integration, a few more testcases, and a lexical-binding assertion.
>
> I'd eventually like to integrate this package into
> the Emacs core, so I've laid claim to a few symbols in the
> global namespace, like next. This package actually defines a generic
> iterator protocol, and it'd be useful eventually to define iterator
> objects for things like buffers and windows instead of relying on
> enumeration callbacks.

First you should package it and put it on marmalade (and melpa?)

If you can do this perhaps the CPS style could just be integrated into
the emacs-lisp interpreter/compiler? then yield could be implemented at
a lower level?

I'm personally uncomfortable about claiming `next'. At least use a
better name, like `gen-next'?

Perhaps it would be possible to avoid grabbing next by making it an
argument to the object returned by yield:

(defgenerator y (x)
   (while (> x 1)
     (setq x (- x 1))
     (yield x)))

(let ((g (y 10)))
  (funcall g :next)
  (funcall g :next)
  (funcall g :next)) => 7


The only thing nicer than that would be to have generators be real
lisp-1 functions:

(let ((g (y 10)))
  (g)
  (g)
  (g)) => 7

this would obviously be a lower level implementation of generators than
some macros can provide.



Other than that it's pretty neat stuff. Definitely this will be useful
for implementing actors/CSP/go routines a la clojure core.async (and Go,
of course).



  reply	other threads:[~2013-08-25  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-25  4:58 RFC: Generators v2 Daniel Colascione
2013-08-25  8:28 ` Nic Ferrier [this message]
2013-08-25 13:56   ` Stephen J. Turnbull
2013-08-25 20:00     ` Daniel Colascione
2013-08-26  3:53       ` Stephen J. Turnbull
2013-08-26 16:05 ` 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=87vc2uyy1o.fsf@ferrier.me.uk \
    --to=nferrier@ferrier.me.uk \
    --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).