The Mesh Engine should support loading (opening) modules.
Proposed approach
Add grammar support for the open keyword which will be used to load modules into the environment.
Two approaches are possible to handle the type checking and evaluation of Mesh expressions involving modules. Let E = [E0, ..., EN] be the list of expressions in a Mesh code block and let the module M be opened in the first expression of the block (i.e.: the first expression is an open expression). Let F = [F0, ..., FM] be the variables defined in the module M. Then either:
All expressions in F are type-checked and evaluated. The type signatures are loaded into the type environment and the values are loaded into the value environment. All expressions in E are type-checked and evaluated using these updated environments.
All expressions in F are prepended to E and the resulting implicit Mesh code block E' = [F0, ..., FM, E0, ..., EN] is evaluated normally.
Description
The Mesh Engine should support loading (opening) modules.
Proposed approach
Add grammar support for the
open
keyword which will be used to load modules into the environment.Two approaches are possible to handle the type checking and evaluation of Mesh expressions involving modules. Let
E = [E0, ..., EN]
be the list of expressions in a Mesh code block and let the moduleM
be opened in the first expression of the block (i.e.: the first expression is anopen
expression). LetF = [F0, ..., FM]
be the variables defined in the moduleM
. Then either:F
are type-checked and evaluated. The type signatures are loaded into the type environment and the values are loaded into the value environment. All expressions inE
are type-checked and evaluated using these updated environments.F
are prepended toE
and the resulting implicit Mesh code blockE' = [F0, ..., FM, E0, ..., EN]
is evaluated normally.