[Top][All Lists]

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

Re: local binding, too local...

From: Jean-Christophe Helary
Subject: Re: local binding, too local...
Date: Sat, 8 Dec 2018 16:37:59 +0900

> On Dec 8, 2018, at 15:48, Yuri Khan <> wrote:
> On Sat, Dec 8, 2018 at 9:19 AM Jean-Christophe Helary
> <> wrote:
>> In a defun I wrote I have a let* block that does something, then some setf 
>> code, then a let block that does something on the values created by setf, 
>> but the let block needs a value that it set in the let* block.
> The customary way is to put the consumer block within the producer block:
>    (defun foo ()
>      (let* ((bar '(baz quux)))
>        (setf (car bar) 'xyzzy)
>        (let ((plugh (cdr bar)))
>          (message "%s" plugh))))

Eventually that's what I did. But I was not sure if that would be considered a 
"hack" or is the correct way to think about things.

>> I would like to keep things local, but not *that* local, just *defun* local.
>> Is there a clean way to declare variables local to a defun and without being 
>> locked by let\*? blocks ?
> let and let* are *binding* forms, not *assignment* statements. The
> bindings go in scope, the body is executed, the bindings go out of
> scope.
> setq, on the other hand, is an assignment form. If a named variable
> exists in the current scope, it will reset its value.

I'm not sure I understand the difference yet between binding and assigning yet.

Jean-Christophe Helary
----------------------------------------------- @brandelune

reply via email to

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