emacs-devel
[Top][All Lists]
Advanced

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

Re: Why is FUNC in cl-callf not allowed to be an expression?


From: Andy Moreton
Subject: Re: Why is FUNC in cl-callf not allowed to be an expression?
Date: Tue, 21 May 2019 08:26:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.50 (windows-nt)

On Mon 20 May 2019, Stefan Monnier wrote:

>> Sorry that I haven't been clear: I want EXPR to eval to the function to
>> be applied, not to the expression to set to.  Like in
>>
>>   (cl-callf (with (if flag #'1+ #'1-)) my-number)
>
> Note that the gv-modify macro we discussed does not allow that either:
> it doesn't funcall the result of an EXPR.
>
> So, what you want can be written
>
>     (cl-callf (lambda (x) (if flag (1+ x) (1- x))) my-number)
> or
>     (cl-callf (lambda (x) (funcall (if flag #'1+ #'1-) x)) my-number)

The documentation for `cl-callf' says:

    Set PLACE to (FUNC PLACE ARGS...).
    FUNC should be an unquoted function name.  PLACE may be a symbol,
    or any generalized variable allowed by ‘setf’.

Please update this (and `cl-callf2') to show that FUNC can be a lambda.

Thanks,

    AndyM






reply via email to

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