I found that in the Rascal console, after I import a module which contains global variable definitions, these global variables are not accessible. Only global function names are accessible. For example, in the following code, after I import Foo
in the console, I can call x()
to get 1
, but dereference x
gives me an unbound variable error. Why?
module Foo
int x = 1;
int x() = 1;
Globals are default private
in Rascal, to prevent you from easily doing such nastiness :-)
module Foo
public int x = 1;
int x() = 1;
This is a bit inconsistent, since the function is public
by default but not when you consider that we will eventually remove globals from the language :-)