Environments |
During the compilation, each scope inside a program corresponds to an environment. During the declaration phase, the environment is filled up with declarations of variables, functions, converters, types and modules. During the actual compilation, the environments do no longer change, except for the “environment cache” for frequent computations (e.g. inferred conversions or function applications). Classes and modules naturally come with their environments, part of which may be public and imported into other environments.
There are several types of environments:
This is the top-level environment.
This is a local environment which is used during the compilation of local bodies and in particular bodies of lambda expressions. More precisely, the primitives which use use lambda environments are lambda, map, begin, loop and where.
This is a special environment with macros for simplied method access. More precisely, any class field x or method foo can be accessed simply by x or foo inside the method environment instead of this.x or this.foo.
This is a local environment with all declarations relative to a class. Part of the declarations may be declared public, so as to be visible in the parent environment.
This is similar to class environments, except that modules do not support intern class fields and that public declarations are not automatically exported to the parent environment.