GNU bug report logs - #38072
when `byte-compile-file' finds out that a file is `no-byte-compile', it ignores `load' parameter

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Tue, 5 Nov 2019 21:00:02 UTC

Severity: minor

Tags: patch

Fixed in version 28.1

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38072 in the body.
You can then email your comments to 38072 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Tue, 05 Nov 2019 21:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 05 Nov 2019 21:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: when `byte-compile-file' finds out that a file is `no-byte-compile', 
 it ignores `load' parameter
Date: Tue, 5 Nov 2019 21:58:55 +0100
After (byte-compile-file "..." t) one normally expects that the file
is loaded, all its functions and variables are visible etc.  However,
if file contains local variable `no-byte-compile', not only
compilation is cancelled, `byte-compile-file' also doesn't load the
file.

Expected: if `byte-compile-file' cancels byte-compilation and `load'
is non-nil, it should load the uncompiled source instead.

Paul




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Sat, 05 Sep 2020 00:31:01 GMT) Full text and rfc822 format available.

Message #8 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Sat, 5 Sep 2020 00:30:38 +0000
[Message part 1 (text/plain, inline)]
tags 38072 + patch
thanks

Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> After (byte-compile-file "..." t) one normally expects that the file
> is loaded, all its functions and variables are visible etc.  However,
> if file contains local variable `no-byte-compile', not only
> compilation is cancelled, `byte-compile-file' also doesn't load the
> file.
>
> Expected: if `byte-compile-file' cancels byte-compilation and `load'
> is non-nil, it should load the uncompiled source instead.

The fix is pretty simple (see attached), but I'm not sure what the
correct behavior is here.

The doc string of `byte-compile-file' says:

    Compile a file of Lisp code named FILENAME into a file of byte code.
    The output file’s name is generated by passing FILENAME to the
    function ‘byte-compile-dest-file’ (which see).
    With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
                                                               ^^^^^^^^^^^^^^^

So should we load the file if we did not compile the file?  I'm thinking
yes, and I don't see what it could hurt to change it to load the file.
If the user uses a prefix arg or the LOAD argument from Lisp, surely
that was the intention.

But on the other hand the text above seems deliberate, somehow?  (And
AFAICT the behavior has been not to load the file since pretty much
forever, possibly since byte-compilation was first added.)

Any other opinions here?

Best regards,
Stefan Kangas
[0001-Ensure-byte-compile-file-loads-file-with-non-nil-loa.patch (text/x-diff, attachment)]

Added tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sat, 05 Sep 2020 00:31:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Sat, 05 Sep 2020 06:22:01 GMT) Full text and rfc822 format available.

Message #13 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefan <at> marxist.se>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: pogonyshev <at> gmail.com, 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Sat, 05 Sep 2020 09:21:02 +0300
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Sat, 5 Sep 2020 00:30:38 +0000
> Cc: 38072 <at> debbugs.gnu.org
> 
>     Compile a file of Lisp code named FILENAME into a file of byte code.
>     The output file’s name is generated by passing FILENAME to the
>     function ‘byte-compile-dest-file’ (which see).
>     With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
>                                                                ^^^^^^^^^^^^^^^
> 
> So should we load the file if we did not compile the file?  I'm thinking
> yes, and I don't see what it could hurt to change it to load the file.
> If the user uses a prefix arg or the LOAD argument from Lisp, surely
> that was the intention.
> 
> But on the other hand the text above seems deliberate, somehow?  (And
> AFAICT the behavior has been not to load the file since pretty much
> forever, possibly since byte-compilation was first added.)

I'm indeed bothered by backward incompatibility of such a change.
Paul expected the file to be loaded unconditionally, but how do we
know someone else isn't expecting the opposite in this case?  Also, do
we want the same behavior in the interactive case?

At the very least, if we decide to install this, the change in
behavior should be in NEWS.

Stefan, any comments on this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Sat, 05 Sep 2020 15:27:02 GMT) Full text and rfc822 format available.

Message #16 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, pogonyshev <at> gmail.com,
 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Sat, 05 Sep 2020 11:26:16 -0400
>>     Compile a file of Lisp code named FILENAME into a file of byte code.
>>     The output file’s name is generated by passing FILENAME to the
>>     function ‘byte-compile-dest-file’ (which see).
>>     With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
>>                                                                ^^^^^^^^^^^^^^^
>> 
>> So should we load the file if we did not compile the file?  I'm thinking
>> yes, and I don't see what it could hurt to change it to load the file.
>> If the user uses a prefix arg or the LOAD argument from Lisp, surely
>> that was the intention.
>> 
>> But on the other hand the text above seems deliberate, somehow?  (And
>> AFAICT the behavior has been not to load the file since pretty much
>> forever, possibly since byte-compilation was first added.)
>
> I'm indeed bothered by backward incompatibility of such a change.
> Paul expected the file to be loaded unconditionally, but how do we
> know someone else isn't expecting the opposite in this case?  Also, do
> we want the same behavior in the interactive case?
>
> At the very least, if we decide to install this, the change in
> behavior should be in NEWS.
>
> Stefan, any comments on this?

FWIW, I find the "and load" feature to be a mistake: the function should
return whether or not it successfully compiled the file, but shouldn't
offer to load the result, since the callers can just as easily do
it themselves (and then they can easily control what happens when
compilation did not succeed).
So, I'd suggest we deprecate that "feature" rather than try and decide
which behavior is better.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Mon, 07 Sep 2020 16:38:02 GMT) Full text and rfc822 format available.

Message #19 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, Eli Zaretskii <eliz <at> gnu.org>
Cc: pogonyshev <at> gmail.com, 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Mon, 7 Sep 2020 09:37:29 -0700
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> FWIW, I find the "and load" feature to be a mistake: the function should
> return whether or not it successfully compiled the file, but shouldn't
> offer to load the result, since the callers can just as easily do
> it themselves (and then they can easily control what happens when
> compilation did not succeed).
> So, I'd suggest we deprecate that "feature" rather than try and decide
> which behavior is better.

It's pretty convenient when running interactively though.  I've tried
using `C-u M-x byte-compile-file' (instead of my usual eval-buffer) for
the last couple of days, and I kind of like getting both
byte-compilation and load-file in one command.

But if we do deprecate this, is there a better alternative that we can
point users to?  Should we just tell them to run two commands?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Mon, 07 Sep 2020 16:45:02 GMT) Full text and rfc822 format available.

Message #22 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 38072 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, pogonyshev <at> gmail.com
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Mon, 07 Sep 2020 16:44:10 +0000
Stefan Kangas <stefan <at> marxist.se> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>> FWIW, I find the "and load" feature to be a mistake: the function should
>> return whether or not it successfully compiled the file, but shouldn't
>> offer to load the result, since the callers can just as easily do
>> it themselves (and then they can easily control what happens when
>> compilation did not succeed).
>> So, I'd suggest we deprecate that "feature" rather than try and decide
>> which behavior is better.
>
> It's pretty convenient when running interactively though.  I've tried
> using `C-u M-x byte-compile-file' (instead of my usual eval-buffer) for
> the last couple of days, and I kind of like getting both
> byte-compilation and load-file in one command.
>
> But if we do deprecate this, is there a better alternative that we can
> point users to?  Should we just tell them to run two commands?

Hi Stefan,

would having the load performed by `emacs-lisp-byte-compile-and-load' an
option?

Ciao

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Sun, 13 Sep 2020 13:07:01 GMT) Full text and rfc822 format available.

Message #25 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 38072 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, pogonyshev <at> gmail.com
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Sun, 13 Sep 2020 06:06:30 -0700
Andrea Corallo <akrl <at> sdf.org> writes:

>>> FWIW, I find the "and load" feature to be a mistake: the function should
>>> return whether or not it successfully compiled the file, but shouldn't
>>> offer to load the result, since the callers can just as easily do
>>> it themselves (and then they can easily control what happens when
>>> compilation did not succeed).
>>> So, I'd suggest we deprecate that "feature" rather than try and decide
>>> which behavior is better.
>>
>> But if we do deprecate this, is there a better alternative that we can
>> point users to?  Should we just tell them to run two commands?
>
> would having the load performed by `emacs-lisp-byte-compile-and-load' an
> option?

Yes, that is good.  I didn't know about that command.

So I agree with Stefan M that the prefix argument should be deprecated.
Do we have a process for that or should it just be removed?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Sun, 13 Sep 2020 14:53:01 GMT) Full text and rfc822 format available.

Message #28 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 38072 <at> debbugs.gnu.org, pogonyshev <at> gmail.com, monnier <at> iro.umontreal.ca,
 akrl <at> sdf.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Sun, 13 Sep 2020 17:52:06 +0300
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Sun, 13 Sep 2020 06:06:30 -0700
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, Eli Zaretskii <eliz <at> gnu.org>, pogonyshev <at> gmail.com, 
> 	38072 <at> debbugs.gnu.org
> 
> So I agree with Stefan M that the prefix argument should be deprecated.
> Do we have a process for that or should it just be removed?

We cannot just remove it.  We should document that it's deprecated and
use advertised-calling-convention to advertise the signature without
it (which will also produce a warning about using the argument in some
situations).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Mon, 21 Sep 2020 22:31:02 GMT) Full text and rfc822 format available.

Message #31 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: akrl <at> sdf.org, pogonyshev <at> gmail.com, monnier <at> iro.umontreal.ca,
 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Mon, 21 Sep 2020 22:30:30 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> So I agree with Stefan M that the prefix argument should be deprecated.
>> Do we have a process for that or should it just be removed?
>
> We cannot just remove it.  We should document that it's deprecated and
> use advertised-calling-convention to advertise the signature without
> it (which will also produce a warning about using the argument in some
> situations).

How about the attached patch?
[0001-byte-compile-file-Make-optional-LOAD-argument-obsole.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Tue, 22 Sep 2020 02:30:02 GMT) Full text and rfc822 format available.

Message #34 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: akrl <at> sdf.org, pogonyshev <at> gmail.com, monnier <at> iro.umontreal.ca,
 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Tue, 22 Sep 2020 05:28:56 +0300
> From: Stefan Kangas <stefan <at> marxist.se>
> Date: Mon, 21 Sep 2020 22:30:30 +0000
> Cc: 38072 <at> debbugs.gnu.org, pogonyshev <at> gmail.com, monnier <at> iro.umontreal.ca, 
> 	akrl <at> sdf.org
> 
> > We cannot just remove it.  We should document that it's deprecated and
> > use advertised-calling-convention to advertise the signature without
> > it (which will also produce a warning about using the argument in some
> > situations).
> 
> How about the attached patch?

OK, but I'd prefer not to rename the argument itself, as that would
get in the way of understanding the code.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#38072; Package emacs. (Tue, 20 Oct 2020 16:57:02 GMT) Full text and rfc822 format available.

Message #37 received at 38072 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: akrl <at> sdf.org, pogonyshev <at> gmail.com, monnier <at> iro.umontreal.ca,
 38072 <at> debbugs.gnu.org
Subject: Re: bug#38072: when `byte-compile-file' finds out that a file is
 `no-byte-compile', it ignores `load' parameter
Date: Tue, 20 Oct 2020 16:56:07 +0000
close 38072 28.1
thanks

Eli Zaretskii <eliz <at> gnu.org> writes:

>> > We cannot just remove it.  We should document that it's deprecated and
>> > use advertised-calling-convention to advertise the signature without
>> > it (which will also produce a warning about using the argument in some
>> > situations).
>>
>> How about the attached patch?
>
> OK, but I'd prefer not to rename the argument itself, as that would
> get in the way of understanding the code.

Thanks, so I fixed that and pushed to master as commit 4a575eb18c.




bug marked as fixed in version 28.1, send any further explanations to 38072 <at> debbugs.gnu.org and Paul Pogonyshev <pogonyshev <at> gmail.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 20 Oct 2020 16:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 18 Nov 2020 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.