emacs-devel
[Top][All Lists]
Advanced

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

Re: Help with recursive destructive function


From: Stefan Monnier
Subject: Re: Help with recursive destructive function
Date: Thu, 07 Jun 2018 09:59:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> I think this function could be useful in many situations, so I'd like to
> make it fairly general -- gv-refs or values.

Why "or values"?  It's easy for the caller to wrap its argument in
`(gv-ref ...)` and lets the function be more efficient.

> How would you feel about gv-ref itself doing a check?
>
> (if (and (eq 'closure (caar place))
>          (eq 'closure (cadr place)))
>     place
>   (gv-letplace ...etc...)
>
> Too hacky?

Beside the obvious problem of checking equality vs `closure` which will
break down with byte-compiled code, the more serious problem is that
this code is run at macro-expansion time, not at run-time, so `place` is
a Elisp *expression* and not an Elisp *value*.

IOW your test will only trigger when the *source code* is of the form

    (gv-ref ((closure ...) . (closure ...)))


-- Stefan




reply via email to

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