From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Generators (iterators) for Gnu Emacs Date: Fri, 05 Dec 2014 13:32:32 -0500 Message-ID: References: <877fy77zhp.fsf@web.de> <87lhmm24x9.fsf@gmail.com> <54812545.6030008@dancol.org> <87d27y22lp.fsf@gmail.com> <87lhmmiim7.fsf@gmail.com> <5481D080.7000206@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1417804380 26521 80.91.229.3 (5 Dec 2014 18:33:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Dec 2014 18:33:00 +0000 (UTC) Cc: Leo Liu , emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 05 19:32:52 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 1XwxgR-0003MD-Bu for ged-emacs-devel@m.gmane.org; Fri, 05 Dec 2014 19:32:51 +0100 Original-Received: from localhost ([::1]:51936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwxgR-0008SO-0i for ged-emacs-devel@m.gmane.org; Fri, 05 Dec 2014 13:32:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwxgH-0008Rx-7T for emacs-devel@gnu.org; Fri, 05 Dec 2014 13:32:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xwxg9-0000ra-Kx for emacs-devel@gnu.org; Fri, 05 Dec 2014 13:32:41 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:59173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xwxg9-0000rG-Hr for emacs-devel@gnu.org; Fri, 05 Dec 2014 13:32:33 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj8PAOwQflRMCqTq/2dsb2JhbABbgweDYIVaxRkEBAICgSQXAQEBAQEBfIQDAQEDAVYjBQsLDiYSFBgNJIhKCdZZAQEIAgEfkDwzB4RIBYsBpC6BeIQZIYJ3AQEB X-IPAS-Result: Aj8PAOwQflRMCqTq/2dsb2JhbABbgweDYIVaxRkEBAICgSQXAQEBAQEBfIQDAQEDAVYjBQsLDiYSFBgNJIhKCdZZAQEIAgEfkDwzB4RIBYsBpC6BeIQZIYJ3AQEB X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="99657590" Original-Received: from 76-10-164-234.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.234]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Dec 2014 13:32:32 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 8318287F8; Fri, 5 Dec 2014 13:32:32 -0500 (EST) In-Reply-To: <5481D080.7000206@dancol.org> (Daniel Colascione's message of "Fri, 05 Dec 2014 10:34:24 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:178978 Archived-At: > I'd really rather signal to stop iteration. That way, it's harder to igno= re > end-of-iteration and loop forever and it remains possible to iterate over > *any* value. condition-case is setjmp. I'm not *that* concerned by > performance. The only other reasonable alternative is for iterators to > yield a cons (terminal-p . value), and consing is going to be much worse > than condition-case. The alternative I was thinking was to return a unique value, as in: (defvar gen-eog (make-symbol "=A1end-of-generator!")) (defun gen-eog-p (x) (eq x gen-oeg)) In terms of efficiency it should be fine (contrary to consing, indeed). Stefan