From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: RFC: rough draft of Python-style generators for elisp Date: Tue, 27 Nov 2012 15:24:19 -0600 Message-ID: <50B52F83.6010600@dancol.org> References: <50B4309C.5000109@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig3EE30C0834A5F3A643F6DC31" X-Trace: ger.gmane.org 1354051517 10131 80.91.229.3 (27 Nov 2012 21:25:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Nov 2012 21:25:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: Burton Samograd Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 27 22:25:29 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TdSem-0004hz-8x for ged-emacs-devel@m.gmane.org; Tue, 27 Nov 2012 22:25:28 +0100 Original-Received: from localhost ([::1]:41980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdSea-0001oI-Og for ged-emacs-devel@m.gmane.org; Tue, 27 Nov 2012 16:25:16 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdSeT-0001nI-Nv for emacs-devel@gnu.org; Tue, 27 Nov 2012 16:25:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdSeN-0006oI-IS for emacs-devel@gnu.org; Tue, 27 Nov 2012 16:25:09 -0500 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:50429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdSeN-0006ng-Cc for emacs-devel@gnu.org; Tue, 27 Nov 2012 16:25:03 -0500 Original-Received: from 68-24-131-234.pools.spcsdns.net ([68.24.131.234] helo=edith.local) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1TdSeL-0004t0-Cb; Tue, 27 Nov 2012 13:25:02 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: X-Enigmail-Version: 1.4.6 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:155110 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3EE30C0834A5F3A643F6DC31 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/27/12 9:31 AM, Burton Samograd wrote: > Daniel Colascione writes: >=20 >> 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. >=20 > When I try and byte-compile your package I get the following: Thanks for trying the package. I've updated it to use pcase, and I fixed the compilation issues by side effect. A few warnings about unused lexical variables remain, but I'm convinced these warnings are spurious. Please let me know if you have any other problems. --------------enig3EE30C0834A5F3A643F6DC31 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: GPGTools - http://gpgtools.org iEYEARECAAYFAlC1L4MACgkQ17c2LVA10Vsz/QCffc4FNqH5gQqxllNlNNh6Rpm+ fdAAn1IMg4wce47NA53aCH4+3gC5L9sB =LZa5 -----END PGP SIGNATURE----- --------------enig3EE30C0834A5F3A643F6DC31--