* Did `inline' used to do something else?
@ 2017-11-18 21:14 Eric Abrahamsen
2017-11-19 0:05 ` Emanuel Berg
2017-11-19 9:53 ` Joost Kremers
0 siblings, 2 replies; 17+ messages in thread
From: Eric Abrahamsen @ 2017-11-18 21:14 UTC (permalink / raw)
To: help-gnu-emacs
The function `inline' is an alias for `progn'.
Gnus is full of code where inline is called with a single argument, ie a
no-op, which makes me think `inline' used to do something else? I've
tried searching git logs, with no results -- did this function used to
actually inline code?
Thanks,
Eric
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-18 21:14 Did `inline' used to do something else? Eric Abrahamsen
@ 2017-11-19 0:05 ` Emanuel Berg
2017-11-19 0:38 ` Eric Abrahamsen
2017-11-19 9:53 ` Joost Kremers
1 sibling, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2017-11-19 0:05 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen wrote:
> The function `inline' is an alias for
> `progn'.
>
> Gnus is full of code where inline is called
> with a single argument, ie a no-op, which
> makes me think `inline' used to do something
> else? I've tried searching git logs, with no
> results -- did this function used to actually
> inline code?
What does "inline" do in other languages?
Instead of calling functions, their code gets
inserted which sometimes can be
a performance advantage?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 0:05 ` Emanuel Berg
@ 2017-11-19 0:38 ` Eric Abrahamsen
2017-11-19 2:01 ` Emanuel Berg
0 siblings, 1 reply; 17+ messages in thread
From: Eric Abrahamsen @ 2017-11-19 0:38 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> Eric Abrahamsen wrote:
>
>> The function `inline' is an alias for
>> `progn'.
>>
>> Gnus is full of code where inline is called
>> with a single argument, ie a no-op, which
>> makes me think `inline' used to do something
>> else? I've tried searching git logs, with no
>> results -- did this function used to actually
>> inline code?
>
> What does "inline" do in other languages?
> Instead of calling functions, their code gets
> inserted which sometimes can be
> a performance advantage?
Which makes me think it used to be some alternate form of macro. It
doesn't appear to do anything now, though.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 0:38 ` Eric Abrahamsen
@ 2017-11-19 2:01 ` Emanuel Berg
2017-11-19 5:59 ` Eric Abrahamsen
0 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2017-11-19 2:01 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen wrote:
>> What does "inline" do in other languages?
>> Instead of calling functions, their code
>> gets inserted which sometimes can be
>> a performance advantage?
>
> Which makes me think it used to be some
> alternate form of macro. It doesn't appear to
> do anything now, though.
OK, so just remove it where there is a single
inhabitant, and replace it with plain `progn'
when there are many?
But yes, would be interesting to know. I have
all my Lisp (LISP) books in another realm, but
I'll look it up ("inline") if I get to them
again, or they to me...
Love computer history :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 2:01 ` Emanuel Berg
@ 2017-11-19 5:59 ` Eric Abrahamsen
0 siblings, 0 replies; 17+ messages in thread
From: Eric Abrahamsen @ 2017-11-19 5:59 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> Eric Abrahamsen wrote:
>
>>> What does "inline" do in other languages?
>>> Instead of calling functions, their code
>>> gets inserted which sometimes can be
>>> a performance advantage?
>>
>> Which makes me think it used to be some
>> alternate form of macro. It doesn't appear to
>> do anything now, though.
>
> OK, so just remove it where there is a single
> inhabitant, and replace it with plain `progn'
> when there are many?
Sure, but I'm a little wary of doing that when I don't really understand
what they were there for in the first place..
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-18 21:14 Did `inline' used to do something else? Eric Abrahamsen
2017-11-19 0:05 ` Emanuel Berg
@ 2017-11-19 9:53 ` Joost Kremers
2017-11-19 10:00 ` Joost Kremers
` (2 more replies)
1 sibling, 3 replies; 17+ messages in thread
From: Joost Kremers @ 2017-11-19 9:53 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: help-gnu-emacs
On Sat, Nov 18 2017, Eric Abrahamsen wrote:
> The function `inline' is an alias for `progn'.
>
> Gnus is full of code where inline is called with a single
> argument, ie a
> no-op, which makes me think `inline' used to do something else?
> I've
> tried searching git logs, with no results -- did this function
> used to
> actually inline code?
I looked at the source to see where it is defined and found the
following in `byte-run.el':
;; Redefined in byte-optimize.el.
;; This is not documented--it's not clear that we should
promote it.
(fset 'inline 'progn)
At first, I couldn't find the referenced file `byte-optimize.el',
so I went back in time, but this `fset' call plus comment was
already present in what seems to be the first version of
`byte-run.el' from 25 years ago. Then I noticed that there is a
file called `byte-opt.el' and indeed, this is the file being
referred to. It contains the following:
;;; byte-compile optimizers to support inlining
(put 'inline 'byte-optimizer 'byte-optimize-inline-handler)
Followed by a definition of `byte-optimize-inline-handler'.
There's no mention of the symbol property `byte-optimizer', and I
know next to nothing about byte compilation, but its name is
suggestive, of course. (In fact, all `defsubst' does is to define
a function and to put this property in the function symbol's plist
with the value `byte-compile-inline-expand'.)
So, long story short, even though `inline' is presented as an
alias for `progn', it's handled differently by the byte compiler,
presumably to deal with performance bottlenecks.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 9:53 ` Joost Kremers
@ 2017-11-19 10:00 ` Joost Kremers
2017-11-19 15:01 ` Emanuel Berg
2017-11-19 16:02 ` Michael Heerdegen
2 siblings, 0 replies; 17+ messages in thread
From: Joost Kremers @ 2017-11-19 10:00 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: help-gnu-emacs
On Sun, Nov 19 2017, Joost Kremers wrote:
> Followed by a definition of `byte-optimize-inline-handler'.
> There's no mention
> of the symbol property `byte-optimizer'
I meant to add "in the Elisp manual" here...
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 9:53 ` Joost Kremers
2017-11-19 10:00 ` Joost Kremers
@ 2017-11-19 15:01 ` Emanuel Berg
2017-11-19 16:02 ` Michael Heerdegen
2 siblings, 0 replies; 17+ messages in thread
From: Emanuel Berg @ 2017-11-19 15:01 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers wrote:
> So, long story short, even though `inline' is
> presented as an alias for `progn', it's
> handled differently by the byte compiler,
> presumably to deal with
> performance bottlenecks.
?!
It works like that?
I thought an alias was always and only an alias
and nothing more. But here you are saying it is
an alias only with respect to the user, not WRT
the byte-compiler?
Wow!
We probably meed to find the source for the
byte compiler to see how and when it acts upon
"inline"!
PS. Good work! DS.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 9:53 ` Joost Kremers
2017-11-19 10:00 ` Joost Kremers
2017-11-19 15:01 ` Emanuel Berg
@ 2017-11-19 16:02 ` Michael Heerdegen
2017-11-19 17:17 ` Emanuel Berg
` (2 more replies)
2 siblings, 3 replies; 17+ messages in thread
From: Michael Heerdegen @ 2017-11-19 16:02 UTC (permalink / raw)
To: Joost Kremers; +Cc: Eric Abrahamsen, help-gnu-emacs
Joost Kremers <joostkremers@fastmail.fm> writes:
>
> ;;; byte-compile optimizers to support inlining
>
> (put 'inline 'byte-optimizer 'byte-optimize-inline-handler)
>
> Followed by a definition of `byte-optimize-inline-handler'. There's no
> mention of the symbol property `byte-optimizer' [...]
That property is referenced by `byte-optimize-form' (in "byte-opt.el").
Also see the flag `byte-optimize'.
If you set `byte-optimize-log', you should be able to get a log of
applied optimizations when compiling something.
Michael.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 16:02 ` Michael Heerdegen
@ 2017-11-19 17:17 ` Emanuel Berg
2017-11-19 20:48 ` Eric Abrahamsen
2017-11-20 3:56 ` Emanuel Berg
2 siblings, 0 replies; 17+ messages in thread
From: Emanuel Berg @ 2017-11-19 17:17 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen wrote:
> That property is referenced by
> `byte-optimize-form' (in "byte-opt.el").
> Also see the flag `byte-optimize'.
>
> If you set `byte-optimize-log', you should be
> able to get a log of applied optimizations
> when compiling something.
Is there a list anywhere of aliases that are
"more than meets the eye"?
Is this only a byte-compiler thing or does it
happen elsewhere?
By the way it is interesting that Gnus is what
brought this issue up to date because Gnus (or
Emacs Lisp) has speed issues and one way in
Gnus to counteract it is the presence of
very long functions.
I suppose inlining could be a way to have
modular, fast code all at once (short, or at
least not marathon functions, that invoke each
other back and forth in code, while huge blocks
in execution).
Still, to have what appears to be just an alias
like this seems a bit risky. Set the docstring
for the alias?
(defalias SYMBOL DEFINITION
&optional DOCSTRING)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 16:02 ` Michael Heerdegen
2017-11-19 17:17 ` Emanuel Berg
@ 2017-11-19 20:48 ` Eric Abrahamsen
2017-11-19 21:16 ` Emanuel Berg
2017-11-20 3:56 ` Emanuel Berg
2 siblings, 1 reply; 17+ messages in thread
From: Eric Abrahamsen @ 2017-11-19 20:48 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Joost Kremers <joostkremers@fastmail.fm> writes:
>
>>
>> ;;; byte-compile optimizers to support inlining
>>
>> (put 'inline 'byte-optimizer 'byte-optimize-inline-handler)
>>
>> Followed by a definition of `byte-optimize-inline-handler'. There's no
>> mention of the symbol property `byte-optimizer' [...]
>
> That property is referenced by `byte-optimize-form' (in "byte-opt.el").
> Also see the flag `byte-optimize'.
>
> If you set `byte-optimize-log', you should be able to get a log of
> applied optimizations when compiling something.
Thanks a bunch to both of you! That was a very interesting deep dive,
and I hope will eventually allow me to write better code.
I suppose the new-ish `define-inline' can be used instead of making
explicit calls to `inline', but either way I'll try to make sure I
preserve the effect.
Emanuel Berg <moasen@zoho.com> writes:
[...]
> By the way it is interesting that Gnus is what
> brought this issue up to date because Gnus (or
> Emacs Lisp) has speed issues and one way in
> Gnus to counteract it is the presence of
> very long functions.
My observation so far is that Gnus has lots of this sort of
micro-optimization, but that much of the slowness comes from how the
larger routines and data structures work. In fairness, we have a lot of
tools now that weren't present when Gnus was written.
Eric
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 20:48 ` Eric Abrahamsen
@ 2017-11-19 21:16 ` Emanuel Berg
2017-11-19 22:06 ` Eric Abrahamsen
0 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2017-11-19 21:16 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen wrote:
>> By the way it is interesting that Gnus is
>> what brought this issue up to date because
>> Gnus (or Emacs Lisp) has speed issues and
>> one way in Gnus to counteract it is the
>> presence of very long functions.
>
> My observation so far is that Gnus has lots
> of this sort of micro-optimization, but that
> much of the slowness comes from how the
> larger routines and data structures work.
> In fairness, we have a lot of tools now that
> weren't present when Gnus was written.
With respect to data structures? What tools
are those?
I always thought data structures
(e.g., balanced search trees) were either
pre-computers (the Turing era) or at the very
latest 50s and 60s stuff.
But maybe I was wrong, or maybe you meant
something else?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 21:16 ` Emanuel Berg
@ 2017-11-19 22:06 ` Eric Abrahamsen
2017-11-19 22:51 ` Emanuel Berg
0 siblings, 1 reply; 17+ messages in thread
From: Eric Abrahamsen @ 2017-11-19 22:06 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> Eric Abrahamsen wrote:
>
>>> By the way it is interesting that Gnus is
>>> what brought this issue up to date because
>>> Gnus (or Emacs Lisp) has speed issues and
>>> one way in Gnus to counteract it is the
>>> presence of very long functions.
>>
>> My observation so far is that Gnus has lots
>> of this sort of micro-optimization, but that
>> much of the slowness comes from how the
>> larger routines and data structures work.
>> In fairness, we have a lot of tools now that
>> weren't present when Gnus was written.
>
> With respect to data structures? What tools
> are those?
Mostly real hash tables, and object classes. I suspect using those will
make things go a bit faster -- at the very least it will reduce the
amount of boilerplate code.
It's possible that threading will provide some speedups, but I'm not
certain.
We'll see! My main goals is making the code more readable and
maintainable, but hopefully some speed improvements will come out of
that as well.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-19 16:02 ` Michael Heerdegen
2017-11-19 17:17 ` Emanuel Berg
2017-11-19 20:48 ` Eric Abrahamsen
@ 2017-11-20 3:56 ` Emanuel Berg
2017-11-20 4:04 ` Emanuel Berg
2 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2017-11-20 3:56 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen wrote:
>> ;;; byte-compile optimizers to support
>> inlining (put 'inline 'byte-optimizer
>> 'byte-optimize-inline-handler) Followed by
>> a definition of
>> `byte-optimize-inline-handler'. There's no
>> mention of the symbol property
>> `byte-optimizer' [...]
>
> That property is referenced by
> `byte-optimize-form' (in "byte-opt.el").
> Also see the flag `byte-optimize'.
(require 'bytecomp)
(get 'push 'byte-compile) ; nil, i.e. no special treatment
;; sort of special treatment
(get 'car 'byte-compile) ; byte-compile-one-arg
(get 'aref 'byte-compile) ; byte-compile-two-args
;; very special (specific) treatment
(get 'progn 'byte-compile) ; byte-compile-progn
(get 'inline 'byte-compile) ; byte-compile-progn
But specific as it might be, there is no
distinction between `inline' and `progn'
visible here. Does `get' even get the
difference or are the two last lines identical
as far as it is concerned?
When is an alias an alias and when is it what
is being aliased?
I think this is only confusing... an alias
should be another way of referring to something
as a convenience, nothing more. Well, hell.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-20 3:56 ` Emanuel Berg
@ 2017-11-20 4:04 ` Emanuel Berg
2017-11-20 19:31 ` Michael Heerdegen
0 siblings, 1 reply; 17+ messages in thread
From: Emanuel Berg @ 2017-11-20 4:04 UTC (permalink / raw)
To: help-gnu-emacs
YT wrote:
> But specific as it might be, there is no
> distinction between `inline' and `progn'
> visible here.
OK, found it - commented lines below is the
yanked result of evaluation:
(symbol-plist 'inline)
;; (byte-compile byte-compile-progn
;; byte-optimizer
;; byte-optimize-inline-handler)
(symbol-plist 'progn)
;; (lisp-indent-function 0
;; byte-hunk-handler
;; byte-compile-file-form-progn
;; byte-compile byte-compile-progn
;; gv-expander [...] [butlast last gv-get
;; progn append] 10 " (fn DO &rest
;; EXPS)"])
> I think this is only confusing... an alias
> should be another way of referring to
> something as a convenience, nothing more.
Agree 100%
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Did `inline' used to do something else?
2017-11-20 4:04 ` Emanuel Berg
@ 2017-11-20 19:31 ` Michael Heerdegen
0 siblings, 0 replies; 17+ messages in thread
From: Michael Heerdegen @ 2017-11-20 19:31 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> > I think this is only confusing... an alias
> > should be another way of referring to
> > something as a convenience, nothing more.
>
> Agree 100%
In my eyes it is absolutely obvious that we have a (documentation) bug:
you need to know something about `inline' to understand the Emacs Elisp
sources, and that "something" is neither obvious nor documented (look
how long it lasted for several experienced people to find out the magic
behind it). And it is confusing to define it with `defalias' because
you get an ridiculing help buffer.
Even when there should be better alternatives now, as long as it's used
so often in Emacs, developers need to know what it does and how it works
to be able to create patches e.g. for Gnus. It can be obsoleted, or the
documentation can say "old, use this and that instead, ...", but that's
not an excuse for missing documentation.
I reported it as a bug (#29367).
Michael.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2017-11-20 19:31 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-18 21:14 Did `inline' used to do something else? Eric Abrahamsen
2017-11-19 0:05 ` Emanuel Berg
2017-11-19 0:38 ` Eric Abrahamsen
2017-11-19 2:01 ` Emanuel Berg
2017-11-19 5:59 ` Eric Abrahamsen
2017-11-19 9:53 ` Joost Kremers
2017-11-19 10:00 ` Joost Kremers
2017-11-19 15:01 ` Emanuel Berg
2017-11-19 16:02 ` Michael Heerdegen
2017-11-19 17:17 ` Emanuel Berg
2017-11-19 20:48 ` Eric Abrahamsen
2017-11-19 21:16 ` Emanuel Berg
2017-11-19 22:06 ` Eric Abrahamsen
2017-11-19 22:51 ` Emanuel Berg
2017-11-20 3:56 ` Emanuel Berg
2017-11-20 4:04 ` Emanuel Berg
2017-11-20 19:31 ` Michael Heerdegen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).