Significance of global keyword

It is global scope, it is the only possibility and you do not need to use the keyword global there. You use global when you want to refer to a global variable inside a block, specially if the block start assigning a value to the global variable (e.g., function f(...); global x = 1; ...; end). Without the global it is indistinguishable from just creating a local variable of the same name (i.e., function f(...); x = 1; ...; end).

Complementing what @mauro3 said, you could ask yourself, but what if I am in the REPL outside of any module?, well, then you are inside the implicit module called Main, and every variable you define in the REPL are global variables of this implicit module.

7 Likes