A2S needs a 'switch' construct, to avoid 'if' chains and similar constructs, for cleaner code and faster execution.
Desired features:
Clean, simple syntax
Multiple values per case
Range cases
Variable cases
The syntax should probably be something like this:
switch x {
1: XIsOne
2 3 4: DoSomething x
5 {
debug 5
Five
}
6..9: InRange x
A: XEqualsA
*: debug x
}
Note that both "N:" and "N {...}" are already existing constructs that mean completely different things in other contexts, but within a 'switch', there probably isn't much risk of confusion. It's not ideal, but what are the (reasonable) options?
On the VM side, this should probably be implemented as one generic SWITCH instruction, which supports mixed value, range, and register cases, and at least one optimized instruction for the "values only" case.
A2S needs a 'switch' construct, to avoid 'if' chains and similar constructs, for cleaner code and faster execution.
Desired features:
The syntax should probably be something like this:
Note that both "N:" and "N {...}" are already existing constructs that mean completely different things in other contexts, but within a 'switch', there probably isn't much risk of confusion. It's not ideal, but what are the (reasonable) options?
On the VM side, this should probably be implemented as one generic SWITCH instruction, which supports mixed value, range, and register cases, and at least one optimized instruction for the "values only" case.