lean4
lean4 copied to clipboard
feat: add namespace utility function
It was pointed out in std4#184 that this function is frequently reimplemented and that it may find a better home here.
Functions I found implementing this function or a variant:
Lean.Elab.mkDeclNameLean.Elab.Command.elabSyntaxdoesn't use the function, but should (see #2239). That PR introduces 4 reimplementations of the functionLean.Elab.Term.elabWithDeclNameshould also be using the function (basically every use of(← getCurrNamespace) ++ idis suspect)
I'm wondering if removing the _root_ prefix from the rhs is a bit excessive. Maybe the user should decide whether to remove it afterwards.
I think the function should be specced to always remove the _root_ prefix and return a fully qualified name. The use code can put _root_ on the front if needed. It shouldn't add the _root_ always because _root_ prefixed names aren't valid fully qualified names, they are a directive to whatever is processing the name to (suppress additional namespaces and) remove the _root_ before using the name, so you would only want to use that when putting the name back into syntax or similar to be re-processed.
Should it then also remove _root_ from the namespace prefix, or just assume that it is a proper namespace?
Namespaces can't have _root_.
So it is fine as is, with a small edit to the docs?
Fixed!