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

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

Re: replacing a function with another one


From: Michael Heerdegen
Subject: Re: replacing a function with another one
Date: Mon, 17 Mar 2014 13:00:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

lee <lee@yun.yagibdah.de> writes:

> Ah!  Finally I understand what the difference is!  What is the point of
> having two variations of `let'?

Both are useful.  The standard `let' works similar to how arguments of a
lambda expression are bound.  If the expressions expr1, expr2, ... in a
`let' form

  (let ((v1 expr1)
        (v2 expr2)
      ...)
  body)

are side-effect free, the bindings of the `let' are interchangeable and
independent from each other, which makes code easier to read in general.

OTOH, `let*' provides the possibility to refer to bindings made earlier,
which is often what you want.
But to the cost that every binding may depend on prior bindings in the
same `let*', which makes it harder to read.

BTW, there is also a parallel setting operator named `psetq' or
`cl-psetq' respectively.  For example, to interchange the values bound
to the variables a, b, you can do

   (psetq a b b a)


Michael.




reply via email to

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