title: How can I refer to a module variable in a function without referring to its module in Elixir 1.0.3? In its parent scope?
body: <p>I'd like to make a function in Elixir 1.0.3 refer to a variable inside its "parent" scope. In this case, its parent scope is a module. </p>
  
  <p>Here's the same code as that which I used in my last question: </p>
  
  <pre><code>defmodule Rec do
    def msgurr(text, n) when n &lt;= 1 do
      IO.puts text
    end
  
    def msgurr(text, n) do
      IO.puts text
      msgurr(text, n - 1)
    end
  end
  </code></pre>
  
  <p>If I change it to the following: </p>
  
  <pre><code>defmodule Rec do
    counter = "done!"
    def msgurr(text, n) when n &lt;= 1 do
      IO.puts text
      IO.puts Rec.counter
    end
  
    def msgurr(text, n) do
      IO.puts text
      msgurr(text, n - 1)
    end
  end
  </code></pre>
  
  <p>It compiles just fine, but I get the following error if I try the msgurr function: </p>
  
  <pre><code>** (UndefinedFunctionError) undefined function: Rec.counter/0
      Rec.counter()
      recursion_and_import_test.exs:5: Rec.msgurr/2
  </code></pre>
  
  <p>I also tried the following: </p>
  
  <pre><code>defmodule Rec do
    counter = "done!"
    def msgurr(text, n) when n &lt;= 1 do
      import Rec
      IO.puts text
      IO.puts Rec.counter
    end
  
    def msgurr(text, n) do
      IO.puts text
      msgurr(text, n - 1)
    end
  end
  </code></pre>
  
  <p>I get a compile-time warnings here, though: 
      ➜  ubuntu  elixirc recursiontest.exs
      recursion_and_import_test.exs:1: warning: redefining module Rec
      recursion_and_import_test.exs:2: warning: variable counter is unused
      recursion_and_import_test.exs:4: warning: unused import Rec</p>
  
  <p>When I attempt to use the msgurr function: </p>
  
  <p>➜  ubuntu  iex
  Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [async-threads:10] [kernel-poll:false]</p>
  
  <pre><code>Interactive Elixir (1.0.3) - press Ctrl+C to exit (type h() ENTER for help)
  iex(1)&gt; import Rec
  nil
  iex(2)&gt; Rec.msgurr("blah", 3)
  blah
  blah
  blah
  ** (UndefinedFunctionError) undefined function: Rec.counter/0
      Rec.counter()
      recursiontest.exs:6: Rec.msgurr/2
  </code></pre>
  
  <p>I seem to be unable to import a variable of my own from a module into a function inside that module. </p>
  
  <p>I've gone over the import documentation, but I can't seem to make much sense from it of how to do this sort of thing. Should I check the Erlang docs? </p>