unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42691: 28.0.50; eval-and-compile
@ 2020-08-03  7:57 Helmut Eller
  2020-08-03  9:29 ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Helmut Eller @ 2020-08-03  7:57 UTC (permalink / raw)
  To: 42691

Compiling this example:

  (require 'cl-lib)
  (cl-macrolet ((foo () '123))
    (eval-and-compile (foo)))

with

  emacs -Q --batch -f batch-byte-compile bug.el

prints:

  In toplevel form:
  bug.el:2:1: Error: Symbol’s function definition is void: foo

I think when compiling eval-and-compile the macro-environment is not
passed along properly.


In GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-08-03 built on caladan
Repository revision: e1f09607e02eb507b229285ed48b85a3c6a50259
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03  7:57 bug#42691: 28.0.50; eval-and-compile Helmut Eller
@ 2020-08-03  9:29 ` Andreas Schwab
  2020-08-03 10:27   ` Helmut Eller
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2020-08-03  9:29 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 42691

On Aug 03 2020, Helmut Eller wrote:

> Compiling this example:
>
>   (require 'cl-lib)
>   (cl-macrolet ((foo () '123))
>     (eval-and-compile (foo)))
>
> with
>
>   emacs -Q --batch -f batch-byte-compile bug.el
>
> prints:
>
>   In toplevel form:
>   bug.el:2:1: Error: Symbol’s function definition is void: foo
>
> I think when compiling eval-and-compile the macro-environment is not
> passed along properly.

Only the body of eval-and-compile is evaluated at that point.  If you
want to modify the environment of the evaluation, you need to move that
modification inside the eval-and-compile form.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03  9:29 ` Andreas Schwab
@ 2020-08-03 10:27   ` Helmut Eller
  2020-08-03 12:04     ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Helmut Eller @ 2020-08-03 10:27 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 42691

On Mon, Aug 03 2020, Andreas Schwab wrote:

> On Aug 03 2020, Helmut Eller wrote:
>
>> Compiling this example:
>>
>>   (require 'cl-lib)
>>   (cl-macrolet ((foo () '123))
>>     (eval-and-compile (foo)))
>>
>> with
>>
>>   emacs -Q --batch -f batch-byte-compile bug.el
>>
>> prints:
>>
>>   In toplevel form:
>>   bug.el:2:1: Error: Symbol’s function definition is void: foo
>>
>> I think when compiling eval-and-compile the macro-environment is not
>> passed along properly.
>
> Only the body of eval-and-compile is evaluated at that point.  If you
> want to modify the environment of the evaluation, you need to move that
> modification inside the eval-and-compile form.

Are you saying this is not a bug in eval-and-compile?

The docstring of eval-and-compile says eval-and-compile is like progn,
except that the body it is evaluated at compile-time too.  If it is
supposed to work like progn, then the environment should be defined as
for progn.

Helmut





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03 10:27   ` Helmut Eller
@ 2020-08-03 12:04     ` Andreas Schwab
  2020-08-03 12:55       ` Helmut Eller
  2021-09-16 15:01       ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Schwab @ 2020-08-03 12:04 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 42691

On Aug 03 2020, Helmut Eller wrote:

> Are you saying this is not a bug in eval-and-compile?

Yes.

> The docstring of eval-and-compile says eval-and-compile is like progn,
> except that the body it is evaluated at compile-time too.  If it is
> supposed to work like progn, then the environment should be defined as
> for progn.

At runtime, yes.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03 12:04     ` Andreas Schwab
@ 2020-08-03 12:55       ` Helmut Eller
  2020-08-03 13:16         ` Andreas Schwab
  2021-09-16 15:01       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Helmut Eller @ 2020-08-03 12:55 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 42691

On Mon, Aug 03 2020, Andreas Schwab wrote:

> On Aug 03 2020, Helmut Eller wrote:
>
>> Are you saying this is not a bug in eval-and-compile?
>
> Yes.
>
>> The docstring of eval-and-compile says eval-and-compile is like progn,
>> except that the body it is evaluated at compile-time too.  If it is
>> supposed to work like progn, then the environment should be defined as
>> for progn.
>
> At runtime, yes.

So you are arguing, that the body should be evaluated and macro-expanded
in the null environment.  That's not like progn at all.  Obviously, I
disagree.  I also note that

  emacs -Q --batch -l bug.el

prints:

  Eager macro-expansion failure: (void-function foo)
  Eager macro-expansion failure: (void-function foo)
  Symbol’s function definition is void: foo

which I also consider a bug.

Helmut





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03 12:55       ` Helmut Eller
@ 2020-08-03 13:16         ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2020-08-03 13:16 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 42691

On Aug 03 2020, Helmut Eller wrote:

> So you are arguing, that the body should be evaluated and macro-expanded
> in the null environment.

No, I don't.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#42691: 28.0.50; eval-and-compile
  2020-08-03 12:04     ` Andreas Schwab
  2020-08-03 12:55       ` Helmut Eller
@ 2021-09-16 15:01       ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-16 15:01 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 42691, Helmut Eller

Andreas Schwab <schwab@linux-m68k.org> writes:

>> Are you saying this is not a bug in eval-and-compile?
>
> Yes.

I think that's correct -- the `eval-and-compile' makes the contents
evaluate in contexts where it otherwise wouldn't be evaluated.  But it
doesn't make the enclosing forms be evaluated in those contexts, so in
this case, they have to be moved down inside the `eval-and-compile'.

So this seems to be working as designed, and I'm closing this bug
report.  (If I misunderstood what this was about, please respond to the
debbugs address and we'll reopen.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-16 15:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03  7:57 bug#42691: 28.0.50; eval-and-compile Helmut Eller
2020-08-03  9:29 ` Andreas Schwab
2020-08-03 10:27   ` Helmut Eller
2020-08-03 12:04     ` Andreas Schwab
2020-08-03 12:55       ` Helmut Eller
2020-08-03 13:16         ` Andreas Schwab
2021-09-16 15:01       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).