Zulip Chat Archive

Stream: lean4

Topic: why `whatsnew`?


Asei Inoue (Nov 17 2024 at 14:26):

why whatsnew command is not defined with name #whatsnew?
this seems to be a diagnostic command.

Asei Inoue (Nov 17 2024 at 14:27):

I have many times typed #whatsnew and got a syntax error. I just can't remember it.

Damiano Testa (Nov 17 2024 at 14:59):

I suspect that this is because whatsnew is a fairly "old" command, that might have been initially meant for debugging only (maybe?) and possibly before there was a convention of prefixing commands with #.

Joachim Breitner (Nov 17 2024 at 15:15):

Note that not all commands are prefixed with # - after all, def is a command. The rule tbst I once heard is that commands that don't change the environment get a # (e.g. #eval, #print)

Asei Inoue (Nov 17 2024 at 15:38):

is PR welcome?

Mauricio Collares (Nov 17 2024 at 17:05):

In general, PRs to core are not welcome unless a RFC issue is opened first and it core developers comment positively on it. There are exceptions to the rule, though.

Asei Inoue (Nov 17 2024 at 17:05):

OK. I will open an issue

Asei Inoue (Nov 17 2024 at 17:10):

In general, PRs to core are not welcome

whatsnew is in Mathlib

Asei Inoue (Nov 17 2024 at 17:14):

I guess you could ask on Zulip if we could rename whatsnew command to #whatsnew.

Kyle Miller (Nov 17 2024 at 18:36):

@Joachim Breitner Though #eval can modify the environment! It accepts CommandElabM values.

Mauricio Collares (Nov 17 2024 at 18:43):

Asei Inoue said:

In general, PRs to core are not welcome

whatsnew is in Mathlib

Ah, my bad! I just looked at the channel name and forgot to check.

Joachim Breitner (Nov 17 2024 at 22:08):

Kyle Miller said:

Joachim Breitner Though #eval can modify the environment! It accepts CommandElabM values.

I didn’t know that (or maybe repressed it). Is there a reason to use #eval here instead of run_cmd (besides that the latter is younger)?

Eric Wieser (Nov 17 2024 at 22:09):

example also seems like a counterexample to this "# iff changes the environment" rule

Joachim Breitner (Nov 17 2024 at 22:09):

Good point.

Joachim Breitner (Nov 17 2024 at 22:10):

It’s just a rule I picked up somewhere, don’t know where, so certainly not authorative. But do we have a better explanation for when to use #?

Kyle Miller (Nov 17 2024 at 22:11):

In mathlib it's sort of "commands that shouldn't stick around in the library"

Eric Wieser (Nov 17 2024 at 22:11):

Is the rule just "be as conservative as you can, because any command keyword you claim will end up illegal in terms; prepend a # if in doubt"?

Joachim Breitner (Nov 17 2024 at 22:13):

Kyle Miller said:

In mathlib it's sort of "commands that shouldn't stick around in the library"

I thought about this, but then #guard_msgs comes to mind. I guess that shouldn’t stick around the library, and tests are different.

Kyle Miller (Nov 17 2024 at 22:13):

Yeah, that's a distinction I'm drawing

Kyle Miller (Nov 17 2024 at 22:14):

I've felt like it would be nice to remove run_cmd etc in favor of #eval (it's now defined in terms of #eval after all), but I suppose that run_cmd doesn't try pretty printing its result, so it's library material.

Eric Wieser (Nov 17 2024 at 22:16):

#guard_msgs is consistent with #guard_expr at least

Joachim Breitner (Nov 17 2024 at 22:24):

For me at least, having the run_xxx commands was a great win, because I could never remember the syntax involving #eval and some ( to me strange) show SomeMonad using do idiom or whatever that was.

Kyle Miller (Nov 17 2024 at 22:25):

You generally don't need to write show ... now, though the inference isn't perfect.

Joachim Breitner (Nov 17 2024 at 22:26):

And the use case “test running some code” and ”do some persistent changes to the environment ” are so fundamentally different that I'd actually prefer different commands, where #eval is always side-effect free (disregarding direct IO)

Kyle Miller (Nov 17 2024 at 22:30):

If I'm experimenting with some elaboration code, I wouldn't want to have to switch from #eval to run_cmd just to use elabCommand

Joachim Breitner (Nov 17 2024 at 22:35):

Oh, read access to the environment based on the monasin question is fine, it's just the final persisting of the effect that I'm surprised by.

Joachim Breitner (Nov 17 2024 at 22:36):

(TBH, all my experimentation starts with the suitable run_cmd or run_meta anyways, I only used #eval for pure calculations. But that largely due to ignorance of what's possible, and habit.)

Kyle Miller (Nov 17 2024 at 22:37):

I mean "just to use elabCommand and observe its results afterwards"

Joachim Breitner (Nov 17 2024 at 22:46):

Fair enough! Different habits, I guess? I certainly didn't want to imply that that needs to change or anything like that. I should probably try using it myself!

Asei Inoue (Dec 21 2024 at 13:13):

Would #whatsnew or #whatsnew be more appropriate?


Last updated: May 02 2025 at 03:31 UTC