* Question about eval and compile-command
@ 2023-08-03 9:29 Eshel Yaron
2023-08-03 9:56 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Eshel Yaron @ 2023-08-03 9:29 UTC (permalink / raw)
To: emacs-devel
Hi all,
I'm curious as to why `compile` and `recompile` use `eval` to evaluate
the value of `compile-command`. AFAICT since commit
5b6858da26e4e6671ee93b67b921a86309b3d6a2 (July 19 2001), these commands
evaluate `compile-command`, as if it's expected to be an expression that
evaluates to a string rather than just a plain string.
The commit message says:
(compilation-parse-errors): `linenum' might return a this-error using
the alternative format (a pair of markers).
But I don't quite understand how that relates to `compile-command`.
Also, the `:type` of `compile-command` remains `string`, and I couldn't
find any mention of the value of `compile-command` being evaluated that
way in the relevant documentation.
I wonder if this is just a remnant of a past experiment or an
undocumented feature. Or maybe there's something else I'm missing?
Thanks,
Eshel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 9:29 Question about eval and compile-command Eshel Yaron
@ 2023-08-03 9:56 ` Eli Zaretskii
2023-08-03 15:14 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2023-08-03 9:56 UTC (permalink / raw)
To: Eshel Yaron, Stefan Monnier; +Cc: emacs-devel
> From: Eshel Yaron <me@eshelyaron.com>
> Date: Thu, 03 Aug 2023 12:29:38 +0300
>
> Hi all,
>
> I'm curious as to why `compile` and `recompile` use `eval` to evaluate
> the value of `compile-command`. AFAICT since commit
> 5b6858da26e4e6671ee93b67b921a86309b3d6a2 (July 19 2001), these commands
> evaluate `compile-command`, as if it's expected to be an expression that
> evaluates to a string rather than just a plain string.
>
> The commit message says:
>
> (compilation-parse-errors): `linenum' might return a this-error using
> the alternative format (a pair of markers).
>
> But I don't quite understand how that relates to `compile-command`.
It doesn't, it describes the change in compilation-parse-errors.
It looks like Stefan added the 'eval' calls as a minor cleanup and not
as part of the change itself. Stefan, any chance you remember why you
added the 'eval' calls?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 9:56 ` Eli Zaretskii
@ 2023-08-03 15:14 ` Stefan Monnier
2023-08-03 16:23 ` Eshel Yaron
2023-08-03 20:02 ` Philip Kaludercic
0 siblings, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2023-08-03 15:14 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Eshel Yaron, emacs-devel
> It looks like Stefan added the 'eval' calls as a minor cleanup and not
> as part of the change itself. Stefan, any chance you remember why you
> added the 'eval' calls?
I added it to allow the `compile-command` to be
(re)computed dynamically.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 15:14 ` Stefan Monnier
@ 2023-08-03 16:23 ` Eshel Yaron
2023-08-03 17:24 ` Stefan Monnier
2023-08-03 20:02 ` Philip Kaludercic
1 sibling, 1 reply; 12+ messages in thread
From: Eshel Yaron @ 2023-08-03 16:23 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel
Thanks Eli, Stefan,
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> It looks like Stefan added the 'eval' calls as a minor cleanup and not
>> as part of the change itself. Stefan, any chance you remember why you
>> added the 'eval' calls?
>
> I added it to allow the `compile-command` to be
> (re)computed dynamically.
I have two followup questions in that case:
1. Given that this is meant to allow recomputing `compile-command`
dynamically, why does `compile` set `compile-command` to its `command`
argument (which is a string, not an expression)? This potentially
causes `compile-command` to only be dynamically evaluated in the first
invocation of `compile`, before being set to a plain string. Consider:
--8<---------------cut here---------------start------------->8---
(let ((compilation-read-command nil)
(compile-command '(concat "echo " (int-to-string (random 100)))))
(call-interactively #'compile)
compile-command)
=> "echo 38"
--8<---------------cut here---------------end--------------->8---
We see that `compile` had the side effect of setting `compile-command`
to a string.
2. Should the manual/docstrings reflect that `compile-command` can be
computed dynamically in this manner? I'd be happy to contribute a patch
documenting this feature, expect I'm not totally sure how users should
best leverage it (see previous question).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 16:23 ` Eshel Yaron
@ 2023-08-03 17:24 ` Stefan Monnier
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2023-08-03 17:24 UTC (permalink / raw)
To: Eshel Yaron; +Cc: Eli Zaretskii, emacs-devel
>> I added it to allow the `compile-command` to be
>> (re)computed dynamically.
> I have two followup questions in that case:
> 1. Given that this is meant to allow recomputing `compile-command`
> dynamically, why does `compile` set `compile-command` to its `command`
> argument (which is a string, not an expression)?
Looks like I overlooked this at the time :-(
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 15:14 ` Stefan Monnier
2023-08-03 16:23 ` Eshel Yaron
@ 2023-08-03 20:02 ` Philip Kaludercic
2023-08-03 20:39 ` Stefan Monnier
2023-08-03 21:14 ` Andreas Schwab
1 sibling, 2 replies; 12+ messages in thread
From: Philip Kaludercic @ 2023-08-03 20:02 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, Eshel Yaron, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> It looks like Stefan added the 'eval' calls as a minor cleanup and not
>> as part of the change itself. Stefan, any chance you remember why you
>> added the 'eval' calls?
>
> I added it to allow the `compile-command` to be
> (re)computed dynamically.
In retrospect, shouldn't the type be be a string or a function? For
former for a static command, the latter for a dynamically computed one?
>
> Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 20:02 ` Philip Kaludercic
@ 2023-08-03 20:39 ` Stefan Monnier
2023-08-03 21:14 ` Andreas Schwab
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2023-08-03 20:39 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: Eli Zaretskii, Eshel Yaron, emacs-devel
>> I added it to allow the `compile-command` to be
>> (re)computed dynamically.
> In retrospect, shouldn't the type be be a string or a function? For
> former for a static command, the latter for a dynamically computed one?
Very definitely.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about eval and compile-command
2023-08-03 20:02 ` Philip Kaludercic
2023-08-03 20:39 ` Stefan Monnier
@ 2023-08-03 21:14 ` Andreas Schwab
2023-08-03 21:35 ` [External] : " Drew Adams
1 sibling, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2023-08-03 21:14 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: Stefan Monnier, Eli Zaretskii, Eshel Yaron, emacs-devel
On Aug 03 2023, Philip Kaludercic wrote:
> In retrospect, shouldn't the type be be a string or a function?
Not a function, but a form.
--
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] 12+ messages in thread
* RE: [External] : Re: Question about eval and compile-command
2023-08-03 21:14 ` Andreas Schwab
@ 2023-08-03 21:35 ` Drew Adams
2023-08-04 5:40 ` Eli Zaretskii
2023-08-04 6:51 ` Andreas Schwab
0 siblings, 2 replies; 12+ messages in thread
From: Drew Adams @ 2023-08-03 21:35 UTC (permalink / raw)
To: Andreas Schwab, Philip Kaludercic
Cc: Stefan Monnier, Eli Zaretskii, Eshel Yaron, emacs-devel@gnu.org
> > In retrospect, shouldn't the type be be a string or a function?
>
> Not a function, but a form.
A string is a form too...
A Lisp object that is intended for
evaluation is called a "form"
https://www.gnu.org/software/emacs/manual/html_node/elisp/Intro-Eval.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Re: Question about eval and compile-command
2023-08-03 21:35 ` [External] : " Drew Adams
@ 2023-08-04 5:40 ` Eli Zaretskii
2023-08-04 6:51 ` Andreas Schwab
1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2023-08-04 5:40 UTC (permalink / raw)
To: Drew Adams; +Cc: schwab, philipk, monnier, me, emacs-devel
> From: Drew Adams <drew.adams@oracle.com>
> CC: Stefan Monnier <monnier@iro.umontreal.ca>, Eli Zaretskii <eliz@gnu.org>,
> Eshel Yaron <me@eshelyaron.com>,
> "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Thu, 3 Aug 2023 21:35:39 +0000
>
> > > In retrospect, shouldn't the type be be a string or a function?
> >
> > Not a function, but a form.
>
> A string is a form too...
Methodologically, it is not good to rely on this, because many Emacs
users will not realize that. We never use "form" when we talk about
strings, for that very reason.
Using mathematical rigor when writing software documentation is almost
never a good idea, in practice.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Re: Question about eval and compile-command
2023-08-03 21:35 ` [External] : " Drew Adams
2023-08-04 5:40 ` Eli Zaretskii
@ 2023-08-04 6:51 ` Andreas Schwab
2023-08-04 7:00 ` Philip Kaludercic
1 sibling, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2023-08-04 6:51 UTC (permalink / raw)
To: Drew Adams
Cc: Philip Kaludercic, Stefan Monnier, Eli Zaretskii, Eshel Yaron,
emacs-devel@gnu.org
On Aug 03 2023, Drew Adams wrote:
>> > In retrospect, shouldn't the type be be a string or a function?
>>
>> Not a function, but a form.
>
> A string is a form too...
But a function does not evaluate to a string.
--
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] 12+ messages in thread
* Re: [External] : Re: Question about eval and compile-command
2023-08-04 6:51 ` Andreas Schwab
@ 2023-08-04 7:00 ` Philip Kaludercic
0 siblings, 0 replies; 12+ messages in thread
From: Philip Kaludercic @ 2023-08-04 7:00 UTC (permalink / raw)
To: Andreas Schwab
Cc: Drew Adams, Stefan Monnier, Eli Zaretskii, Eshel Yaron,
emacs-devel@gnu.org
Andreas Schwab <schwab@linux-m68k.org> writes:
> On Aug 03 2023, Drew Adams wrote:
>
>>> > In retrospect, shouldn't the type be be a string or a function?
>>>
>>> Not a function, but a form.
>>
>> A string is a form too...
>
> But a function does not evaluate to a string.
I'll rephrase my comment to avoid confusion: "Instead of any accepting a
string, or any form (both of which are evaluated, which is not an issue
due to the fact that evaluation of strings is idempotent), it seems like
it would have been better if the expected type of `compile-command' were
either a string, that would be interpreted without any further
processing, or a function, that would be funcalled with the expectation
that it would return a string, which would be taken to be the compile
command."
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-08-04 7:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 9:29 Question about eval and compile-command Eshel Yaron
2023-08-03 9:56 ` Eli Zaretskii
2023-08-03 15:14 ` Stefan Monnier
2023-08-03 16:23 ` Eshel Yaron
2023-08-03 17:24 ` Stefan Monnier
2023-08-03 20:02 ` Philip Kaludercic
2023-08-03 20:39 ` Stefan Monnier
2023-08-03 21:14 ` Andreas Schwab
2023-08-03 21:35 ` [External] : " Drew Adams
2023-08-04 5:40 ` Eli Zaretskii
2023-08-04 6:51 ` Andreas Schwab
2023-08-04 7:00 ` Philip Kaludercic
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.