PLAIN – Events 2

Events and state engine support is a key feature in PLAIN where we do things different. It basically convert the entire application into a state engine where processing is top-down based on events. I am not sure how much of this I want to support directly in the VM, but I will Experiment a bit.

An Event is basically a function that needs to be called with a Raise statement. But, unlike a Call it will not return and instructions after “Raise” is illegal as they never will be executed since we will return to the last Call.

Event is added at the end of a function where you also can add parameters, options and a default body

Func MyFunc
            // function body
Event MyEvent (parameters) options
            // default body
End

Options are Static, Mandatory, Optional.

A static event can not be overridden.

A mandatory event must be overridden.

An optional event (default) can be overridden by the choice of the developer.

The keyword Event is only legal on the end of a function where it also “end” the previous function/event body or after a Call where it will catch mandatory and optional events.

One important feature about event is the “do nothing” rule – if an event is raised and not caught nothing should happen. The Assembler should generate an error, but the VM should execute the Raise and behave as if it was Raise Continue.

Leave a Reply