In Ren-C, we evaluate expressions in SWITCH:
x: 304
switch x [
300 + 4 [
print "this prints in Ren-C"
]
...
]
That is not the case in Rebol2/etc. You get instead the likes of:
switch '+ [
300 + 4 [
print "this will print in R3-Alpha/Rebol2/Red, and it is misguided"
]
...
]
In My View, the Choice Should Be Obvious
For the class of language that Rebol is, SWITCH should evaluate its clauses. Being able to use the evaluator is a force multiplier.
x: 10
switch type of x [
integer! [print "Don't you think this should run?"]
]
Mechanically speaking, it is possible for SWITCH to discern a BLOCK! it evaluated, from one that is referenced directly in the body.
not-literal-wont-print: [print "subtlety"]
switch [print "this need not print"] [
([print "subtlety"]) not-literal-wont-print
([print "subtlety"]) [print "...but this *will* print"]
]
Carl Believed Rebol2 Should Be Challenged
Carl questioned the issue when asking if SWITCH should be made a native:
The switch function is used quite frequently in programs, but it presents challenges to new users, due to it's non-evaluated case labels.
He also said, circa 2014:
Having taken a long break from Rebol development, I guess these days I'm more in favor of disruption and going down a better path for new users. As I've said many times, Rebol 3 is still in alpha. That means we get to fix stuff and make it better. Sorry if it's a bit disruptive. There are always a few bumps in the development road, but you can
['t (sic)]
be afraid to keep moving forward.
You Can Of Course Write A Compatibility Version
Here's a bit of emulation from the "Redbol" module (that adds /DEFAULT back in too!)
switch: emulate [
enclose (augment :switch [
/default "Default case if no others are found"
[block!]
]) lambda [f [frame!]] [
f.cases: map-each c f.cases [
match block! c else [quote c] ; suppress eval on non-blocks
]
let def: f.default ; the DO expires frame right now (for safety)
(eval f else (def)) else [@none]
]
]