Global variables const by default?

If we could mark the type of a variable in global scope we wouldn’t need to think about making globals constants.
E.g.
myvar::Int64 = 1
in global scope.
Actually, I miss this feature even inside functions.

:confused:

function f()
    x::Int64 = 0
    x = "foo" # error
end
1 Like

Ohh, great!

Do you know why we cannot do the same in global scope?

That Traceur.jl could over the poster code :slight_smile: .

Actually having a linter available as an interactive tool for discourse posts would be cool. (actually not a bad idea having a linter server which can be indicated, where one could copy/paste MWE and get hints of possible problems).

No intrinsic reason, it’s just not implemented yet. Cf

https://github.com/JuliaLang/julia/issues/964

1 Like