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: return Date: Fri, 26 Nov 2010 13:40:26 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1290796847 31993 80.91.229.12 (26 Nov 2010 18:40:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 26 Nov 2010 18:40:47 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 26 19:40:39 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PM3Dp-0006Nz-9y for ged-emacs-devel@m.gmane.org; Fri, 26 Nov 2010 19:40:37 +0100 Original-Received: from localhost ([127.0.0.1]:55868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PM3Do-0000ge-U4 for ged-emacs-devel@m.gmane.org; Fri, 26 Nov 2010 13:40:36 -0500 Original-Received: from [140.186.70.92] (port=48557 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PM3Dh-0000fj-M8 for emacs-devel@gnu.org; Fri, 26 Nov 2010 13:40:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PM3Dg-0000Mo-9g for emacs-devel@gnu.org; Fri, 26 Nov 2010 13:40:29 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:32279 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PM3Dg-0000Mb-3B for emacs-devel@gnu.org; Fri, 26 Nov 2010 13:40:28 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqQKABaO70xFxKB0/2dsb2JhbACVDI0GfXLALIVHBIRcjW0 X-IronPort-AV: E=Sophos;i="4.59,262,1288584000"; d="scan'208";a="83789810" Original-Received: from 69-196-160-116.dsl.teksavvy.com (HELO ceviche.home) ([69.196.160.116]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 26 Nov 2010 13:40:26 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id B3806660DC; Fri, 26 Nov 2010 13:40:26 -0500 (EST) In-Reply-To: (Lars Magne Ingebrigtsen's message of "Fri, 26 Nov 2010 16:45:12 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133176 Archived-At: >> If this is only "while debugging and fixing stuff", I don't think it's >> a serious enough problem to warrant such a change. > Well, not, that was just what I was doing moments before writing the > email, so it just reminded me. But the style of doing > (defun foo () > (unless condition > (return bar)) > .. compute a bit more > (unless other-condition > (return zot)) > ... do the real foo work here) > feels kinda natural. It's what some people calls "guard based > programming". Without it, you end up with > (defun foo () > (if (not condition) > bar > .., compute a bit more > (if (not other-condition) > zot > ... do the real work))) > where you have to read quite a lot of the code to find out what the exit > points are. I feel like the former style often makes it easier to read > the code. Of course, that's what `cond' is for. Now, I know it doesn't always cut it, but I'm still unconvinced that the rare cases where it would really improve the code are worth all the cases where people will end up using it instead of using a cleaner functional style. >> But I'd be OK with adding a `return' from while loops: after all >> `while' loops are naturally imperative, so such a `return' would not >> make things less imperative. > while, dolist, dotimes... Yes, same thing. > The temptation to rewrite loops using the cl-macs `loop' macro can > sometimes be overwhelming, since you can return from the loop easier. You can try the `do' macro, which is not as flexible as `loop', but does correspond fairly simply to a functional recursive loop. We could also provide (and encourage the use of) Scheme's named-let, although it tends to be "too powerful" (not inherently tail-recursive, so making it efficient (CPU-wise and stack-space-wise) would require a good bit more work). > But using `loop' doesn't seem to be in the Emacs Lisp style, I think -- > it's not used a lot, which kinda leads me to think that most Emacs Lisp > programmers don't really know how it works. Indeed. Stefan