# Way to be explicit with different objects sharing the same name?

**URL:** https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961
**Category:** General Usage
**Tags:** question
**Created:** [December 24, 2017, 4:19am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961 "2017-12-24T04:19:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [December 24, 2017, 4:19am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/1 "2017-12-24T04:19:04Z")

</div>

Let’s say you have a module in a package called `IO` (obviously not preferable):

```julia
module IO
  custom_input_output_stuff = true
end

```

The problem now is that the module `IO` will clobber the Base `IO` type in calls.

* * *

This leads to the following errors:

```julia
> foo(bar::IO) = "nope, chuck testa"
ERROR: ArgumentError: invalid type for argument bar in method definition for foo at REPL[10]:100:

> struct Fizz ; buzz::IO ; end 
ERROR: TypeError: Fizz: in type definition, expected Type, got Module

```

* * *

How do you tell the package to use `Base's IO` when a type is expected?

_edit: tangentially related to [Julia Reserved/Key Words](https://discourse.julialang.org/t/julia-reserved-key-words/4781)_

---

<div class="post-metadata">

### Author: ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)
#### Post date: [December 24, 2017, 4:53am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/2 "2017-12-24T04:53:47Z")

</div>

`Base.IO`?

---

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [December 24, 2017, 4:57am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/3 "2017-12-24T04:57:16Z")

</div>

Sorry, but what about it?

The following doesn’t work:

```julia
> IO = Base.IO
ERROR: invalid redefinition of constant IO

```

// all the code above can be entered into the REPL

---

<div class="post-metadata">

### Author: ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)
#### Post date: [December 24, 2017, 5:03am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/4 "2017-12-24T05:03:01Z")

</div>

If I understand (which is a big “if”), your `foo` and `Fizz` only make since if the `IO` is `Base.IO`.

So I would make that

```julia
foo(bar::Base.IO) = "nope, chuck testa"

struct Fizz; buzz::Base.IO ; end

```

---

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [December 24, 2017, 5:08am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/5 "2017-12-24T05:08:27Z")

</div>

That’s right. I was just wondering if there was a succinct way to do this without mass grep & replacing.

For this specific case, it seems like something looking for a Type object should find the Type form of `IO` and not error out?

---

<div class="post-metadata">

### Author: ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)
#### Post date: [December 24, 2017, 9:36am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961/6 "2017-12-24T09:36:05Z")

</div>

No, currently there is no other way, but to use the fully-qualified name of a type.  
e.g. `Base.IO`.

Namespacing issues like that are a problem, and one that deserves a better solution, but until there is one, either avoid reusing names like that or use fully qualified names.
