title: How to define shared constant on Elixir
body: <p>Can I define constant shared with modules?</p>
  
  <p>Generally, we use module attribute for constant inside module.
  <a href="http://elixir-lang.github.io/getting-started/module-attributes.html#as-constants" rel="nofollow noreferrer">http://elixir-lang.github.io/getting-started/module-attributes.html#as-constants</a></p>
  
  <p>If I want to make constant available to other modules, how can I do it?
  At first, module attribute is available just only inside module(1).
  I know I can use function as constant(2).
  But if possible, I want to define constant by dedicated form like 3.</p>
  
  <pre><code>defmodule Sample do
      # 1. module attribute(available only inside module)
      @private_const_value 1
      # 2. function as constant(possible in any rate)
      def const_value_func, do: 3
      # 3. ideal form(but compile error)
      public_const_value = 2
  end
  
  defmodule Client do
      def foo() do
          IO.puts "CONST = #{Sample.@private_const_value}" # compile error
          IO.puts "CONST = #{Sample.const_value_func}"
          IO.puts "CONST = #{Sample.public_const_value}" # compile error
      end
  end
  </code></pre>
  
  <h3>postscript</h3>
  
  <p>I expect that constant satisfies following requirements. </p>
  
  <ul>
  <li>evaluation at compile-time</li>
  <li>classification by module(I means constants should be defined at appropriate module)</li>
  </ul>