I've mentioned before that AUGMENT can be used to implement the legacy SWITCH/DEFAULT behavior.
But looking at what seems like the "correct" formulation of that code today, we get:
switch-d: enclose (augment switch/ [
:default "Default case if no others are found"
[block!]
]) lambda [f [frame!]] [
let def: f.default
eval f else (opt def)
]
It points out the existence of void branches... so not branches that evaluate to void (e.g. []) but code that evaluates to a branch to run, and that branch is void.
If we are considering this specific usage only, it suggests a semantic for ELSE of a VOID branch, which is that you want it to act like there was no branch at all. e.g. as if you'd written just eval f with no ELSE.
>> if 10 > 20 [1 + 2]
== \~,~\ ; antiform (ghost!) "void"
>> if 10 > 20 [1 + 2] else [10 + 20]
== 30
>> if 10 > 20 [1 + 2] else ()
== \~,~\ ; antiform (ghost!) "void"
Would the same apply to THEN?
>> if 1 = 1 [1 + 2]
== 3
>> if 1 = 1 [1 + 2] then [10 + 20]
== 30
>> if 1 = 1 [1 + 2] then ()
== 3
![]()
I don't know if it's great, but it's certainly better than evaluating to NULL, because that would trigger an ELSE branch.
>> if okay [1 + 2] then () else [print "we don't want this."]
we don't want this.
But what should other branching constructs do, like CASE or SWITCH? Might a void branch suggest "opting out" of that particular branch?
case [
1 < 2 ()
3 < 4 [print "Should this run?"]
]
A CASE (at least CASE:ALL) is supposed to be synonymous with a series of IF statements. And IF can't exactly do that, unless it decided to be VOID!...
>> 1 + 2 if 10 > 20 ()
== 3
That would be a bit weird, but, it does sort of parallel what happens when ELSE and THEN effectively vaporize themselves.
As with most things on the edge of usefulness, I don't know about this... other than the situation of wanting to revoke the ELSE branch in SWITCH-D. I'll keep an eye on it.