Zulip Chat Archive

Stream: general

Topic: alias not respecting _root_


Yaël Dillies (Aug 12 2021 at 10:06):

Using _root_ when declaring an alias with alias doesn't actually put it in the root namespace, but appends a _root_ namespace:

namespace foo
def bar : true := trivial
alias bar  _root_.baz
end foo

#check baz -- unknown identifier 'baz'
#check _root_.baz -- _root_.baz : true

Kevin Buzzard (Aug 12 2021 at 10:39):

Sounds like the perfect time for you to learn some C++ Yael!

Eric Wieser (Aug 12 2021 at 10:40):

Alias is written in Lean, isn't it?

Anatole Dedecker (Aug 12 2021 at 12:02):

That's because names declared by alias are always in the root namespace iirc

Eric Wieser (Aug 12 2021 at 12:03):

docs#tactic.alias.alias_cmd

Yaël Dillies (Aug 12 2021 at 12:20):

Aaah, okay. That makes sense

Mario Carneiro (Aug 12 2021 at 15:50):

when alias was written, it wasn't even possible for lean code to know what namespace you are in. It would be good if lean exposed its namespace name resolver to user code, but barring that it should be sufficient to work it out manually given the current namespace (which has a hook)


Last updated: Dec 20 2023 at 11:08 UTC