[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: named-let
From: |
Stefan Monnier |
Subject: |
Re: named-let |
Date: |
Wed, 13 Jan 2021 09:01:26 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> And we can also use approaches like "inline, together with a check that
>> the function was not advised" for functions which have not been
>> officially declared as inlinable (such checks are already used in the
>> native-comp code, IIRC, tho just to use "fast call" rather than do
>> inlining).
>
> I'm not sure I understand it. Given code like
>
> (defun add1 (b)
> (+ b 1))
>
> (defun test ()
> (advice-add (intern "add1") :after (lambda (&rest _)
> (message "Whoa!")))
> (+ 10 (add1 20)))
>
> We want to inline (add1 20) so the program becomes (+ 10 (+ 1 20)). But
> advice can happened at run time.
The inlining would basically lead to the following code:
(+ 10 (if (eq (symbol-function 'add1) <thethingweexpect>) (+ 20 1)
(add1 20)))
which the compiler might be able to optimize to something equivalent to:
(if (eq (symbol-function 'add1) <thethingweexpect>) 31
(+ 10 (add1 20)))
-- Stefan
- Re: named-let, (continued)
- Re: named-let, Tomas Hlavaty, 2021/01/11
- Re: named-let, Andrea Corallo, 2021/01/11
- Re: named-let, Stefan Monnier, 2021/01/11
- Re: named-let, Andrea Corallo, 2021/01/11
- Re: named-let, Stefan Monnier, 2021/01/11
- Re: named-let, Andrea Corallo, 2021/01/12
- Re: named-let, Stefan Monnier, 2021/01/12
- Re: named-let, Andrea Corallo, 2021/01/12
- Re: named-let, Helmut Eller, 2021/01/12
- Re: named-let, Zhu Zihao, 2021/01/13
- Re: named-let,
Stefan Monnier <=
- Re: named-let, Andrea Corallo, 2021/01/11
- Re: named-let, Tomas Hlavaty, 2021/01/11
- Re: named-let, Andrea Corallo, 2021/01/11
- Re: named-let, Tomas Hlavaty, 2021/01/11
Re: named-let, Stefan Monnier, 2021/01/20