Zulip Chat Archive

Stream: mathlib4

Topic: Name.getString


Kim Morrison (May 14 2024 at 00:32):

Currently Mathlib has Name.getString, which is poorly named. It in fact takes the last component of the name, and makes a best effort to represent this as a string:

/-- Get the last field of a name as a string.
Doesn't raise an error when the last component is a numeric field. -/
def getString : Name  String
  | .str _ s => s
  | .num _ n => toString n
  | .anonymous => ""

It is only used in the implementation of @[simps] and @[to_additive]. I'd like to rename it.

Kim Morrison (May 14 2024 at 00:33):

Name.lastComponentAsString? #12891

Kim Morrison (May 14 2024 at 00:33):

or just Name.lastAsString?


Last updated: May 02 2025 at 03:31 UTC