Eve Aspects
Aspects
An "aspect" is a script specific to a particular project. It resolve a problem or address a specific concern. Aspect files are executable. An aspect is an independent, encapsulated machine with the same shape as a driver: declarations and one process main, its entry point, that receives the parameters of the aspect. An aspect can't apply another aspect, so processes can not be recursive; methods can.
An aspect is not instantiated and has no public members: the dot operator is never used with an aspect. Data goes in by the parameters of main and comes out by its output parameters (@). Each call creates the state of the aspect, and the state is dropped when main returns. An aspect is executed with the keyword "apply", in serial mode. Aspects applied in sequence can raise errors like any other process, and the error propagates to the caller. An error that nobody handles ends the application. The driver captures the exit code of panic, raise, expect and assert.
Aspects are independent of each other. An aspect knows nothing of the other aspects: it sees no global of the driver, it can't call a member of another aspect, and no other script can reach into it. Everything it needs comes through the parameters of main, and everything it produces leaves through its output parameters. This is what lets a driver compose aspects freely: an aspect can be tested alone, with a small driver that applies it, and moved to another application without change. Shared code belongs in a module, which every aspect may import.
Aspect skeleton:
** purpose of the aspect
aspect aspect_name is
** declarations of the aspect: private, created at each apply
** and dropped when main returns; an aspect defines no globals
new count = 0 :Integer;
from $path/library_name use (*);
** helper work is done by functions
procedure helper(parameter_list) is
...
return;
** the only process: the entry point
process main(parameter_list) is
** executable region
...
recover
** handle all errors
...
finalize
** release locked resources
...
return;
end aspect_name;
A small application can keep its driver and its aspects in one file: an Eve macro. There the aspects also share the declarations at the top of the file.
Read next: Macros