Zulip Chat Archive

Stream: mathlib4

Topic: Deprecating `str` syntax for docstrings in `to_additive`


Thomas Murrills (Aug 09 2025 at 23:42):

#28135 will (eventually) deprecate str syntax support for additive docstrings, e.g. @[to_additive "I am an additive docstring!"], in favor of docComment syntax, e.g. @[to_additive /-- I am an additive docstring! -/]. Note that it will not remove support for str syntax, but instead will issue a warning and provide a suggestion.

There are two questions I'd like to ask in this thread:

  1. Who should str syntax be deprecated for? As I see it, there are three options: (a.) everyone in mathlib (b.) everyone adhering to mathlib style standards through linter options (c.) everyone
  2. When should support for str be removed, and seeing as the deprecation is not a declaration deprecation, how should this be recorded?

Eric Wieser (Aug 09 2025 at 23:45):

I would say the answer to 1 is (c)

Eric Wieser (Aug 09 2025 at 23:46):

Ideally with a "try this" to make adapting downstream easier

Thomas Murrills (Aug 09 2025 at 23:49):

Eric Wieser said:

I would say the answer to 1 is (c)

Okay—hmm, in that case, I suppose the next question is whether this warning should be (i.) controlled by linter.deprecated (ii.) controlled by a new option (iii.) not controlled by an option.

Thomas Murrills (Aug 09 2025 at 23:50):

Eric Wieser said:

Ideally with a "try this" to make adapting downstream easier

Yup—by "provide a suggestion", I meant "provide a Suggestion"! :)

Eric Wieser (Aug 09 2025 at 23:51):

I think emulating the standard deprecation machinery as much as possible is the right thing to do here

Eric Wieser (Aug 09 2025 at 23:51):

So respect the options, phrase the warning message in the same way, and log with the same tag on the message

Eric Wieser (Aug 09 2025 at 23:52):

Arguably core (and in the meantime, mathlib) should have a helper function for that

Thomas Murrills (Aug 10 2025 at 00:02):

True; I may as well PR that helper function to mathlib first.

Violeta Hernández (Aug 10 2025 at 02:29):

Out of curiosity, what's the benefit of this?

Aaron Liu (Aug 10 2025 at 02:30):

less escaping

Aaron Liu (Aug 10 2025 at 02:30):

more clear it's a docstring since it uses the docstring syntax

Aaron Liu (Aug 10 2025 at 02:30):

gives you better syntax highlighting

Violeta Hernández (Aug 10 2025 at 06:54):

Valid

Thomas Murrills (Aug 10 2025 at 17:20):

Eric Wieser said:

So respect the options, phrase the warning message in the same way, and log with the same tag on the message

Aside: minor point, but I think the phrasing of current deprecation warning code actions should say "Update to: <new>" instead of "Replace <old> with <new>" to (1.) better communicate the fact that this is coming from a deprecation (2.) keep code actions concise. (Also, code formatting is not rendered in code action titles, and so I believe we should avoid backticks if possible. Separation-by-colon is enough, imo.)

Thomas Murrills (Aug 10 2025 at 17:29):

Also, I'm wondering: do we think the suggestion widget text should duplicate the logged message as much as possible, or not?

The argument to the contrary would be that they both appear in the infoview, so duplicating them is noisy; we can instead separate their roles, and have the message be descriptive of the general issue, while the suggestion is only descriptive of the specific change necessary. E.g. the widget could simply say "Update deprecated syntax to:\n<clickable new version>", while the logged message could say "<This kind> of syntax is deprecated: use <this kind> of syntax instead". (If the specific change necessary is large, this could be a more comprehensible description of the issue in a log.)

Thomas Murrills (Aug 10 2025 at 17:34):

Are there contexts where it is useful to have the intended replacement in the logged message per se? For example, are interactive suggestions available in the neovim extension?


Last updated: Dec 20 2025 at 21:32 UTC