From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: Defining functions within functions? Date: Wed, 25 May 2016 08:21:44 +0200 Message-ID: <87twhm64jr.fsf@mbork.pl> References: <87k2ilbblk.fsf@mbork.pl> <87mvngsfiw.fsf@web.de> <874m9n6t3o.fsf@mbork.pl> <1464127858.3032.28.camel@pippiandcarlos.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1464157343 18251 80.91.229.3 (25 May 2016 06:22:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 May 2016 06:22:23 +0000 (UTC) Cc: Michael Heerdegen , help-gnu-emacs@gnu.org To: Carlos Konstanski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 25 08:22:19 2016 Return-path: Envelope-to: geh-help-gnu-emacs@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 1b5SCw-0007D5-Ah for geh-help-gnu-emacs@m.gmane.org; Wed, 25 May 2016 08:22:18 +0200 Original-Received: from localhost ([::1]:57576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5SCv-0000z5-Dy for geh-help-gnu-emacs@m.gmane.org; Wed, 25 May 2016 02:22:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5SCW-0000yh-Dg for help-gnu-emacs@gnu.org; Wed, 25 May 2016 02:21:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5SCT-0004eC-5m for help-gnu-emacs@gnu.org; Wed, 25 May 2016 02:21:52 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:33666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5SCS-0004e7-Ur for help-gnu-emacs@gnu.org; Wed, 25 May 2016 02:21:49 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 706DCBA464B; Wed, 25 May 2016 08:21:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cnOSWE3OvwIl; Wed, 25 May 2016 08:21:45 +0200 (CEST) Original-Received: from localhost (unknown [77.88.191.10]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 67166BA4649; Wed, 25 May 2016 08:21:45 +0200 (CEST) User-agent: mu4e 0.9.16; emacs 25.1.50.1 In-reply-to: <1464127858.3032.28.camel@pippiandcarlos.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110103 Archived-At: On 2016-05-25, at 00:10, Carlos Konstanski wrote: > Am Dienstag, den 24.05.2016, 14:56 -0700 schrieb Drew Adams: >> > >> > And I wanted to use the former variant, but it struck me as not >> > very >> > elegant.As for the latter, I'm not sure I understand it exactly, >> > but >> > I'll give it some thought. >> > >> > For now, I decided to go with lambdas, but also to sprinkle the >> > code >> > with comments.Old-fashioned, but should do the jon in my case. >> A suggestion: Post a concrete example of what you need, and >> see what concrete suggestions you get. >> >> Typically, this stuff is not complicated.The first thing >> to do, IMO, is to determine whether you really need/want to >> do something special/complicated.Why do you think you want >> a nested defun or other form of local function definition? > > My 2 cents: as a common lisp propgrammer, I find two uses for > labels/flet: > > - Recusrion. The wrapping code sets up the initial enviornment and then > calls the inner function where all the real work happens. In all other > languages you need two functions, but in lisp you can package the > entire thing into one form with an inner function. That I don't need. > - Arguments for free: If the flet is defined within the lexical scope > of some bindings, you can treat those bindings as "globals" and not > have to pass them into the function. I'm guessing this is what all the > let-over-lambda talk is about. And those I do use. > Both of these are valid uses of labels. Unless you have code > portability concerns, don't shy away from a package that gives emacs > lisp the same power as the other lisps. If you mean (require 'cl-lib), I do it anyway. And if /I/ didn't, request.el does. > Carlos Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University