# Use of constant types

**URL:** <https://discourse.julialang.org/t/use-of-constant-types/36251>\
**Category:** New to Julia\
**Created:** [March 20, 2020, 10:40am UTC](https://discourse.julialang.org/t/use-of-constant-types/36251 "2020-03-20T10:40:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [March 20, 2020, 10:40am UTC](https://discourse.julialang.org/t/use-of-constant-types/36251/1 "2020-03-20T10:40:41Z")

</div>

I am struggling with the issue of changing the type of a global variable.  
I keep a set of functions I am working on in a file “global\_functions.jl”, which I include in my main program. I then give it a shortcut in the global space, called GF. global\_functions.jl has a module defined with the name “globalFunctions\_mod”:

```julia
include("global_functions.jl")
GF = globalFunctions_mod

```

This is equivalent (more or less) to the python construct

```julia
import globalFunctions_mod as GF

```

As I read more, I decided to make GF into a const variable:

```julia
const GF = globlFunctions_mod

```

and continue working on my program. But I get the error:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/4/24501bbea719e320de8723d5fcf7a67646b1b0d7.png)

This makes programming difficult since it is not possible to remove a variable once it is defined. So my question is: how do I change a variable from non-const to const without recompiling my entire program, which seems rather inefficient. I love Julia so far, but there are some quirks of the language that I am having a serious problem embracing. If it is not possible to solve this problem (I probably just do not know how), I would like to understand better the rationale that prevents this type of transformation.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [March 20, 2020, 10:42am UTC](https://discourse.julialang.org/t/use-of-constant-types/36251/2 "2020-03-20T10:42:50Z")

</div>

Are you using Revise.jl? That is a must-have.

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [March 20, 2020, 12:18pm UTC](https://discourse.julialang.org/t/use-of-constant-types/36251/3 "2020-03-20T12:18:10Z")

</div>

Yes, once you have enough code to define a module, you should put it in a package, use `Revise` to update it, and `import/using` instead of `include` to access it. Then you won’t have any problems.

Doing a package isn’t hard, and it doesn’t have to be public. You can either

- Use `PkgTemplate.jl`
- Create a folder in `.julia/dev/YourPackage`, with `YourPackage/src/YourPackage.jl` containing the source code
- Create that folder elsewhere, but make sure its parent is in the LOAD\_PATH

Then you can `using YourPackage`. Maybe you’ll have to `] dev YourPackage` first.
