Closed nsensfel closed 4 years ago
https://github.com/nsensfel/tonkadur/issues/2 is changing this a bit: sequences can now be returned from.
(done)
(terminate current context, return to parent active context), (continue_as ...)
(terminate current context, initialize a new one), or (end)
(program terminates).(visit ...)
with no following instructions should be transformed into (continue_as ...)
, to avoid uselessly keeping active contexts. This may require some special care with the arguments given to the (visit ...)
instruction.The new implementation of sequences removes the issue of going past the sequence's definition. Thus, the lack of explicit sequence termination is no longer an issue.
Currently, it is possible to write something like:
If (var my_var) is equal to one, the sequence ends without either a jump to another sequence, or an
(end)
instruction. The behavior in this case is undefined (Wyrd will keep on executing code from whatever is next in the code base without even realizing a sequence ended).The compiler should raise an error whenever there is a way to exit the sequence without either
(sequence ...)
or(end)
.One way to go about this is to check on the last instruction, and see if its branches all end in either of these instructions.
Some cases will require the user to add dead code to fulfill this constraint, however:
This is also something programming languages require when defining functions that return a value, and can thus be considered an acceptable compromise.