emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC wi


From: Vibhav Pant
Subject: Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with define-inline.
Date: Sun, 26 Nov 2017 22:36:14 +0530

On Sat, Nov 18, 2017 at 8:23 PM, Stefan Monnier
<address@hidden> wrote:
> Yay, someone dared to use define-inline even though I haven't managed to
> document it yet!

The existing documentation in inline.el is quite easy to understand. I have also
used it in other packages.

> > -(defsubst erc-nickserv-alist-sender (network &optional entry)
> > -  (nth 1 (or entry (assoc network erc-nickserv-alist))))
> > +(define-inline erc-nickserv-alist-sender (network &optional entry)
> > +  (inline-quote (nth 1 (or ,entry (assoc ,network erc-nickserv-alist)))))
>
> When inlined, `entry` will be evaluated before `network`.
> Worse yet: `network` won't be evaluated at all if `entry` is non-nil.
> So it won't behave the same when inlined than when non-inlined, which
> I'd consider as a bug.

I've pushed a fix by using `inline-letevals` to enforce the correct
evaluation order.

> > -(defsubst erc-get-server-user (nick)
> > +(define-inline erc-get-server-user (nick)
> >    "Find the USER corresponding to NICK in the current server's
> >  `erc-server-users' hash table."
> > -  (erc-with-server-buffer
> > -    (gethash (erc-downcase nick) erc-server-users)))
> > +  (inline-quote (erc-with-server-buffer
> > +               (gethash (erc-downcase ,nick) erc-server-users))))
>
> This will evaluate `nick` in another buffer than the caller's
> current-buffer, so if the argument refers to buffer-local variables the
> result may be different when inlined than it would be when not inlined.

I'm not entirely sure on how to fix this. Would reverting to defsubst/defun be
the only solution?

Thanks,
Vibhav

-- 
Vibhav Pant
address@hidden



reply via email to

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