I decided to change the Call Instruction to the one below. As we return with an event code we consume the NIX and process the first “On” that will test for event code and continue to next “On” if not.
At this point I can consider dropping “On” and replace it with “If” or “Switch” – one lesst instruction to worry about. But, I will consider that as all instructions are drafted.
I really like this version of Call as it leaves me with a minimal function call if I don’t need On. Let’s test it out:
Func MyFunc(uint32 x) if( x = 1) Raise E1("Text 1") elseif(x=2) Raise E2(2) else Raise Error(x, "X is wrong value") end Event E1(string s) Event E2(uint32 i) Event Error(uint32 i, string text) End uint32 x for x=1 to 3 Call MyFunc(1) On E1(string s) println("Event E1 is called") On E2(uint32 i) println("Event E2 is called") On Error(uint32 i, string text) println("Error is called") End End
The annotaded figure below show hoe Call would be in this example. I will return to details about On Instructions later.The key with Event’s is that unless it is handled we do nothing, we just fall through. The function will mark Event’s as Optional, Mandatory or Static. If we must have a On we mark it as Mandatory etc.