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

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

Re: 'let' for functions ?


From: Ed L Cashin
Subject: Re: 'let' for functions ?
Date: Sat, 26 Apr 2003 15:19:41 -0400
User-agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386-debian-linux-gnu)

Hannu Koivisto <azure@iki.fi> writes:

> chris@example.org writes:
>
>> I just wondered if it is possible to get the lexical scoping effect for
>> functions that 'let' and related functions provide for variables.
>
> Note that Emacs Lisp is dynamically scoped, thus let does not
> provide lexical scoping but dynamic scoping.
>
>> i.e I want to be able to do something like this :
>>
>> (let ((funca funcb))
>>    (require 'foolib))
>
> You can use flet (or labels if you need recursion) from the cl
> package:
>
> (require 'cl)
>
> (flet ((funca (&rest args)
>          (apply 'funcb args)))
>   (require 'foolib))

As an exercise I tried in vain to create a simple implementation of
labels that wouldn't require loading cl.  I couldn't do it, though,
and had to get on with what I was supposed to be doing.  ;)

I'd be very interested, though, to see such a simple implementation of
labels if there's an elisp guru who would enjoy trying to find it.
The hard part for me was recursion support.

-- 
--Ed L Cashin     PGP public key: http://noserose.net/e/pgp/


reply via email to

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