From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: execute defun on reception of signal Date: Tue, 14 Jul 2015 23:33:43 +0200 Message-ID: <87r3oafmq0.fsf@nl106-137-147.student.uu.se> References: <871tgedtkv.fsf@nl106-137-147.student.uu.se> <86r3odvfg3.fsf@gmail.com> <871tgd9uwi.fsf@nl106-137-147.student.uu.se> <7d1d1e2c-1b1d-490a-a20e-1a06c84e2c87@googlegroups.com> <996d35f0-133b-4760-ac26-cff54f402008@googlegroups.com> <87bnffo3yz.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436909780 23788 80.91.229.3 (14 Jul 2015 21:36:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Jul 2015 21:36:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 14 23:36:07 2015 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 1ZF7ry-0001Pn-6Y for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jul 2015 23:36:06 +0200 Original-Received: from localhost ([::1]:33066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF7rs-0005SY-DP for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Jul 2015 17:36:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF7rK-0005Ng-NX for help-gnu-emacs@gnu.org; Tue, 14 Jul 2015 17:35:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZF7rH-0004Uj-8X for help-gnu-emacs@gnu.org; Tue, 14 Jul 2015 17:35:26 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZF7rH-0004UM-1V for help-gnu-emacs@gnu.org; Tue, 14 Jul 2015 17:35:23 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZF7rE-00016H-TV for help-gnu-emacs@gnu.org; Tue, 14 Jul 2015 23:35:20 +0200 Original-Received: from nl106-137-156.student.uu.se ([130.243.137.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Jul 2015 23:35:20 +0200 Original-Received: from embe8573 by nl106-137-156.student.uu.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 14 Jul 2015 23:35:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-156.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:R4vc65HtIK+efLsvF9LEPmFRe6Y= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105721 Archived-At: "Pascal J. Bourguignon" writes: > Emanuel Berg writes: > >> Rusi writes: >> >>> However on a docs-improving note here's this little titbit: [On other thread] There was this claim "letrec is nice" or some such. Since I know letrec from scheme etc but never seen in elisp I was curious. I find: describe-function tells nothing about the recursion the elisp info pages (index) seems to not have it at all >> There is no mention of "letrec" in >> /usr/share/info/emacs-24/elisp.info I don't know the >> policy. Are *all* functions, macros, etc. >> supposed to be in the Elisp manual? > > letrec is not emacs lisp, it's scheme. OK, but it is here as well: letrec is a Lisp macro in `subr.el'. (letrec BINDERS &rest BODY) Bind variables according to BINDERS then eval BODY. The value of the last form in BODY is returned. Each element of BINDERS is a list (SYMBOL VALUEFORM) which binds SYMBOL to the value of VALUEFORM. All symbols are bound before the VALUEFORMs are evalled. > In Common Lisp, one would use labels, so in emacs > lisp you can write: > > (require 'cl) (defun fact (n) (labels ((f (n f) > (if (plusp n) (f (- n 1) (* n f)) f))) (f n 1))) > > provides a nice tail-recursive > factorial implementation. I know about labels - I don't use them myself as I'm happy to have everything on the same level. Functions do things - they are like tools, and you never now when you need them or in what context. Variables, the other way around, they should be encapsulated in all but exceptional cases. But anyway, why do you bring this up? With letrec, can you do both variables and setup local functions or something like that? -- underground experts united http://user.it.uu.se/~embe8573