# Correct way to declare global constant in modules

**URL:** <https://discourse.julialang.org/t/correct-way-to-declare-global-constant-in-modules/10234>\
**Category:** General Usage\
**Tags:** constants\
**Created:** [April 8, 2018, 8:02pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-global-constant-in-modules/10234 "2018-04-08T20:02:11Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [April 8, 2018, 10:13pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-global-constant-in-modules/10234/6 "2018-04-08T22:13:54Z")

</div>

Guys,

The problem is not related with the global constants, but with the internal `K1`. This other code reproduces the problem as well:

```julia
VERSION >= v"0.4.0-dev+6521" && __precompile__ ()

module TestConst

export test

function test(n::Number, e::Number)
    # Check if the arguments are valid.
    if (n <= 0)
        throw(ArgumentError("The angular velocity must be greater than 0."))
    end

    # Auxiliary constant to compute the functions.
    K1 = 3.0

    # Declare the functions that must solved for 0.
    f1(a, i) = K1
end

end

```

Notice that, if I remove the exceptions, then everything is fine:

```julia
Variables:
  #self# <optimized out>
  n <optimized out>
  e <optimized out>
  K1 <optimized out>
  f1::TestConst.#f1#1{Float64}

```

Am I missing something?

---

_[View the full topic](https://discourse.julialang.org/t/correct-way-to-declare-global-constant-in-modules/10234)._
