On Wednesday, June 4, 2014 12:13:30 AM UTC+8, Mauro wrote:
>
>
> However, there are some subtleties, have a look at the manual 
> http://docs.julialang.org/en/latest/manual/types/ 


On Wednesday, June 4, 2014 9:52:01 AM UTC+8, Andrew Simper wrote:
>
> Is there some obscure reason that the global scope is somehow special when 
> it comes to handing the types of variables?
>
>>
>>
Ahh, ok, I have found the small print, thanks for posting that link:

"Currently, type declarations cannot be used in global scope, e.g. in the 
REPL, since Julia does not yet have constant-type globals. "

Ok, so it sounds this case hasn't been handled yet, fair enough it is only 
v0.3.x and already super useful, and most practical applications I'll be 
writing functions to call anyway. But I think it would make sense even if 
just done for consts since that is already supported at the global level:

>From the page:
http://julia.readthedocs.org/en/latest/manual/variables-and-scoping/#constants

"The const declaration is allowed on both global and local variables, but 
is especially useful for globals. It is difficult for the compiler to 
optimize code involving global variables, since their values (or even their 
types) might change at almost any time. If a global variable will not 
change, adding a const declaration solves this performance problem."

Which is a little confusing when this sort of thing goes on:

<https://lh3.googleusercontent.com/-FrXH_N3Ewas/U46BaHI0hXI/AAAAAAAAAM8/iUT1CLKK1eg/s1600/Screen+Shot+2014-06-04+at+10.15.08+AM.png>





Reply via email to