Zulip Chat Archive

Stream: new members

Topic: Opening namespace causes ambiguity


Mark Fischer (Jan 08 2024 at 16:25):

So, in one file I've created a namespace to define functions without clashing with std names. Is there some way to open a namespace without those name clashes immediately coming back? I'd like to avoid prefixing everything I've defined within a namespace all the time.

Mark Fischer (Jan 08 2024 at 16:28):

What I'm getting right now:

ambiguous, possible interpretations
  _root_.or_assoc [...]
  MyLogic.or_assoc [...]

Patrick Massot (Jan 08 2024 at 16:29):

I'm not sure what you are asking for. Maybe you want open foo (bar) which makes bar accessible instead of foo.bar but nothing else from the foo namespace. Or open foo hiding bar which does the opposite.

namespace foo

def bar : Nat := 0

def baz : Nat := 1

end foo

section
open foo (bar)

#check bar -- works
#check baz -- fails
end

section
open foo hiding bar

#check bar -- fails
#check baz -- works
end

Ruben Van de Velde (Jan 08 2024 at 16:31):

I think the goal is to hide the root versions in favor of the MyLogic ones, which I'm not sure is possible

Mark Fischer (Jan 08 2024 at 16:32):

I'd like to be able to write:

open MyLogic
#check or_assoc

but right now that's ambiguous. Yes, @Ruben Van de Velde has it right.

Mark Fischer (Jan 08 2024 at 16:36):

So I've just noticed that the following seems to work:

namespace MyLogic
#check or_assoc

Last updated: May 02 2025 at 03:31 UTC