[Top][All Lists]

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

Re: cl-lib questions

From: Stefan Monnier
Subject: Re: cl-lib questions
Date: Wed, 21 Jul 2021 17:59:52 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Can you perhaps say a couple of words on the intended use for
> `setf', I get it it is a generic function (macro) but is there
> in your mind say one or two typical use cases or something
> like that to exemplify?

A typical example for me is when you want to modify the field of
a struct:

    (cl-defstruct my-foo a b c)

then you can set the field `b` of a my-foo struct X to value V with:

    (setf (my-foo-b X) V)

I also like to (ab)use it for things like

    (push (make-new-element)
          (if (something)

> Also, what is the difference between setf and `setq' with
> respect to setting `let'/`let*' variables?


> Another cl-lib question is the type of clause usable with
> `cl-loop' that are described like this in the docstring:

I wouldn't know, I never use `cl-loop`.


reply via email to

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