Le jeudi 25 décembre 2014 à 23:32 -0800, [email protected] a écrit :
> I had thought that top level == global, but Milan's statement:
> 
> 
> > No, `global n` is only needed when `n` is in the global scope. Here `n` 
> > is not global, it's local to the enclosing scope.
> 
> 
> suggests its not the case.  Thats why I suggested the manual needs to
> clarify that if it is the case.
Actually what I meant is that `n` is here *also* local to the enclosing
scope, the enclosing scope being the global scope. Thus you don't *need*
to state `global n`. This happens because you're executing code at the
top-level.

(At least that's my understanding of how it works...)


Regards

> 
> Cheers
> Lex
> 
> On Friday, December 26, 2014 4:41:41 PM UTC+10, [email protected]
> wrote:
>         On Wednesday, December 24, 2014 6:08:51 PM UTC-5,
>         [email protected] wrote:
>                 
>                 On Thursday, December 25, 2014 8:29:45 AM UTC+10,
>                 Milan Bouchet-Valat wrote:
>                         Le mercredi 24 décembre 2014 à 10:21 -0800,
>                         [email protected] a 
>                         écrit : 
>                         
>                         > 
>                         > ~~~julia 
>                         > #!/usr/bin/julia 
>                         > 
>                         > n = 1  # top-level variable, aka global 
>                 
>                 
>                 I think the thing missing from the manual is if this
>                 assignment does in fact create a global, or a name in
>                 some sort of file scope?
>                 
>                 
>         
>         I'd just assumed that a global in Julia is a variable defined
>         at file-scope (i.e., top-level). Is that indeed the case?
>         
>         

Reply via email to