help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: execute defun on reception of signal


From: Emanuel Berg
Subject: Re: execute defun on reception of signal
Date: Tue, 14 Jul 2015 23:33:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> Emanuel Berg <embe8573@student.uu.se> writes:
>
>> Rusi <rustompmody@gmail.com> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]