From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Generators (iterators) for Gnu Emacs Date: Fri, 05 Dec 2014 10:54:58 +0100 Organization: Organization?!? Message-ID: <874mtato99.fsf@fencepost.gnu.org> References: <877fy77zhp.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417773377 20360 80.91.229.3 (5 Dec 2014 09:56:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Dec 2014 09:56:17 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 05 10:56:11 2014 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 1XwpcQ-0006kO-NE for ged-emacs-devel@m.gmane.org; Fri, 05 Dec 2014 10:56:10 +0100 Original-Received: from localhost ([::1]:49459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwpcQ-0004fq-9l for ged-emacs-devel@m.gmane.org; Fri, 05 Dec 2014 04:56:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xwpbd-0004Sj-JJ for emacs-devel@gnu.org; Fri, 05 Dec 2014 04:55:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwpbX-0004ue-M6 for emacs-devel@gnu.org; Fri, 05 Dec 2014 04:55:21 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:50477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwpbX-0004qb-6y for emacs-devel@gnu.org; Fri, 05 Dec 2014 04:55:15 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XwpbS-00066b-3s for emacs-devel@gnu.org; Fri, 05 Dec 2014 10:55:10 +0100 Original-Received: from x2f46271.dyn.telefonica.de ([2.244.98.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 05 Dec 2014 10:55:10 +0100 Original-Received: from dak by x2f46271.dyn.telefonica.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 05 Dec 2014 10:55:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: x2f46271.dyn.telefonica.de X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:NmcFlbJ6PBEceGvRnuUOw0TRB2w= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:178896 Archived-At: Stefan Monnier writes: >> (defmacro gen-make (&rest body) >> "Return a generator that evaluates BODY to generate elements. >> For each call of `gen-next' with the the returned generator, BODY >> will be evaluated to produce an element." >> (let ((this-element (make-symbol "this-element"))) >> `(let (,this-element) >> (lambda () > > AFAICT this requires lexical-binding in the caller, so we might want to > signal an error if lexical-binding is nil. Uh what? The whole point of the make-symbol abomination is to get a symbol uniquely used by only one instance of the lambda function. This is _exactly_ in order to _not_ require lexical binding. >> (if (eq ,this-element 'gen-done) >> 'gen-done >> (setq ,this-element (progn ,@body))))))) With lexical binding, this would look something like (defmacro gen-mane (&rest body) `(let (this-element) (lambda () (if (eq this-element 'gen-done) 'gen-done (setq this-element (progn ,@body)))))) And one would be tempted to see whether this really needs to be a macro. -- David Kastrup