Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Use of constant types

$
0
0

@erlebach wrote:

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”:

include("global_functions.jl")
GF = globalFunctions_mod

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

import globalFunctions_mod as GF

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

const GF = globlFunctions_mod

and continue working on my program. But I get the error:
image

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.

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles