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

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

Re: Always using let*


From: Cecil Westerhof
Subject: Re: Always using let*
Date: Mon, 15 Sep 2014 00:11:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Op Sunday 14 Sep 2014 23:25 CEST schreef Drew Adams:

>> Would it be OK to always use let*? I was just bitten by the fact
>> that with let you can not previous variables from the let
>> statement, as is possible with setq. So I am thinking about always
>> using let*, so I do not have to think about it. Or are there good
>> reasons to use let when you do not need let*?
>
> The most common reason is when you want to use a variable value
> in the cadr of a binding and you do *not* want to pick up the
> variable's newly bound value.  IOW, precisely the opposite use
> case of what you wanted when you were bit.
>
> (setq c 3)
>
> (let ((c  (+ c 4))
> (b  (* c 42))) ; Use original C value: 3
> ...)

That makes my head spin. ;-)


> (The other reason is that for some Lisps the bindings of `let'
> can be done in parallel, which can be quicker.)

Nice to know, but in most cases the ‘let*’ will not be the bottleneck.

I think I am going to always use let*. Or maybe I should just engrave
the difference in my brain. After I was bitten, I remembered. Better
to remember before. :-)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


reply via email to

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