# How do I add a function/method to an already defined module

**URL:** <https://discourse.julialang.org/t/how-do-i-add-a-function-method-to-an-already-defined-module/22699>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 3, 2019, 2:38pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-function-method-to-an-already-defined-module/22699 "2019-04-03T14:38:09Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![iPostHuman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iposthuman/32/7463_2.png) [@iPostHuman](https://discourse.julialang.org/u/iPostHuman)\
**Post date:** [April 4, 2019, 7:43pm UTC](https://discourse.julialang.org/t/how-do-i-add-a-function-method-to-an-already-defined-module/22699/7 "2019-04-04T19:43:58Z")

</div>

I would like to thank **mauro3** , **tkoolen** for helping me solve my issue. Here is the simplified version on [Repl.it](https://repl.it/@WilliamDeVore/ValidGreenSoftwaresuite).

I also experience some _weird_ issues with `import`ing. For example, I have two include files:

```julia
include("splash_scene.jl")
include("game_scene.jl")

```

both perform the same import statements:

```julia
import .Ranger.Nodes:
    transition, get_replacement, visit

```

If I forget to import `visit` in either one of the files I get this warning:

```julia
WARNING: import of Nodes.visit into Main conflicts with an existing identifier; ignored.

```

And as a result, the abstract overload is called instead. This is unexpected and in addition I don’t know why Julia issues this. It is true that I should only have only one import for both files—which is what I did to make sure there isn’t an inconsistency—but still it would be nice if Julia could somehow give a better clue to the problem. It took me 20 minutes to realize what the bug was. Basically, if you have this:

```julia
import .Ranger.Nodes:
    transition, get_replacement, visit

... more code and some includes()

import .Ranger.Nodes:
    transition, get_replacement #<--- missing visit import

```

You will get a warning.

Anyway, I am still learning Julia and I enjoy the language even with a few errors on my part.  
The code-in-progress in on [Github](https://github.com/wdevore/Ranger-Julia-SDL) if you are interested.

Below is a stripped down example with two lines marked `important`:

```julia
module Ranger
  module Nodes
    # This is important piece #1
    function transition end

    # Simple demo node for example ----------
    abstract type AbstractNode end

    mutable struct Node <: AbstractNode
      x::Float64
    end

    crossnode = Node(1.0)
    # -------------------------------------

    function visit()
      transition(crossnode)
    end
  end
end

# Demo engine
module Engine
  using ..Ranger.Nodes:
    visit
    
  function run()
    visit()
  end
end

# ------------------
using .Ranger.Nodes:
  AbstractNode, Node

# This is the important piece #2
import .Ranger.Nodes:
  transition

function transition(node::AbstractNode)
  println("abstract node transition")
end

function transition(node::Node)
  println("node transition")
end

# -------------------------
using .Engine:
  run
  
function go()
  run()
end
  
go()

```

---

_[View the full topic](https://discourse.julialang.org/t/how-do-i-add-a-function-method-to-an-already-defined-module/22699)._
