Re: flet vars
- From: RG <rNOSPAMon@xxxxxxxxxxx>
- Date: Fri, 22 Apr 2011 23:13:15 -0700
In article <87aafhbr2g.fsf@xxxxxxxxxxxxxxx>,
Tim X <timx@xxxxxxxxxxxxxxx> wrote:
TheFlyingDutchman <zzbbaadd@xxxxxxx> writes:
Let's take a look at how (let) works:
(defvar a 10)
(defun foo () (setq a -10))
(let ((a 20)) (foo) (print a) ) => -10
And you defend that behavior? Amazing.
I thought I understood some of your 'issues', but now I'm confused? The
above example makes perfect sense to me. Which 'a' were you expecting to
be modified when you call foo within the scope of your let? I'm assuming
you had expected the special (dynamic in your terminology?) to be set to
-10 and for the lexical binding to remain at 20? If that was the
behavior you wanted, isn't that what declare special etc is for?
I must be missing something as the example seems fine to me and
perfectly defensible.
Tim
Suppose I want to make a lexical closure. I type this:
(let ((v 0))
(lambda () (incf v)))
But that may or may not give me a lexical closure depending on whether
or not at some previous point in this current session someone has typed
(defvar v ...) or some such thing. This is why the *earmuffs*
convention was developed, but any time you have to have a rule like that
it's an indication of a poor design. If all special variables should
have earmuffs, why not build that into the language spec?
The answer is that DEFVAR works the way it does not because it's a good
design, but because part of CL's mission statement was to unify
dynamically and lexically scoped lisps. But no one uses dynamically
scoped Lisps any more, so we are saddled with a bad design that was put
in place to satisfy a requirement that no one cares about any more.
rg
.
- Follow-Ups:
- Re: flet vars
- From: Tim Bradshaw
- Re: flet vars
- From: Pascal Costanza
- Re: flet vars
- From: Tim X
- Re: flet vars
- From: Pascal J. Bourguignon
- Re: flet vars
- References:
- flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Ankur
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Captain Obvious
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Captain Obvious
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Thomas A. Russ
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Ankur
- Re: flet vars
- From: TheFlyingDutchman
- Re: flet vars
- From: Tim X
- flet vars
- Prev by Date: Re: string efficiency
- Next by Date: Re: flet vars
- Previous by thread: Re: flet vars
- Next by thread: Re: flet vars
- Index(es):
Relevant Pages
|