All code in Plain Assembly is within a module. A module is in effect a process, a stand-alone Plain application that is downloaded to the VM and executed.
A module is used by a different module with a use statement
use system module mymodule system.println("Hello World") end
This example re-use the module “system” in “mymodule”.
Only one module can be declared in a single file and the file prefix must be the same as the module name. A module can be declared in multiple files (TBD).
Modules can contain global code that is the “main” on a module executed top Down.
The current draft allows content to be mixed in no particular order – you can write statements, declare a function and write new statements using that function etc. It is a discussion that we maybe should be stricter and implement concepts used in Pascal where everything must be declared in groups. This part of the Pascal syntax is known to enhance structure and readability. The drawback is that we start bloating our modules by doing this. Large modules will benefit, while small modules will not (TBD).
Components inside a module is private to that module and cannot be accessed from other modules unless they are prefixed with the keyword “Interface”.
... Module 32xIO ... Interface Object Channel ... End ... End
A module can be controlled by another module
StartProcess (MyModule)
This will cause the VM to start executing the module MyModule in parallel with the current module. It will only signal the module to execute – it takes no parameters and will return events like a normal function.
Functions like StartProcess, StopProcess, IsProcessRunning etc are part of theVM’s own C interface and accessed through the System module.
Notice that StartProcess will start executing the global code in a module as a process, it does not affect interface parts of the same module. Also keep in mind that a module can be remote, so a call to system.println() might execute a function located top-side on your host computer. What happens in this case is that we send the “call” through easyIPC to the different device and return the event the same way. This is part of the distributed processing logic build into Plain VM/easyIPC.