So on this note: what if we presume values and branches alternate, unless COMMA! is used...in which case each element of the comma clause is assumed to be a value to match?
That would avoid the explicit search for BLOCK!, allowing QUOTED! and GROUP! branches:
>> x: 5
>> switch x [
1 [2 3]
4, 5 '[6]
]
== [6]
You'd be able to switch on blocks:
>> x: [a b]
>> switch x [
[a b] [print "first match!"]
]
first match!
>> x: [a b]
>> switch x [
[a b], [c d] [print "first match!"]
]
first match!
>> x: [a b]
>> switch x [
[a b], [c d] '[print "first match!"]
]
== [print "first match!"]
You'd still be able to match commas, though we might have to make it legal to say ',, ... for now it works if you space it out:
>> x: ',
>> switch x [
1, ', , 2 [print "match!"]
]
match!
Weird, but, if it comes up you could express it. For those concerned with legibility, there's other ways since it's an evaluative slot:
switch x [
1, first [,], 2 [print "match!"]
]
This seems like it might be a good compromise, and normal cases should look pretty good:
switch type of x [
integer!, block! [
print "It was an integer or a block"
]
]
The same feature could be implemented for CASE. Since commas cannot appear internally to single expressions, the only place they could have appeared would have been right before the branch anyway.
case [
x > 5, x < 20 [
print "This would be kind of cool, eh?"
]
y > 10,
y < 1000 [
print "Looks good with multiple lines too."
]
]
But in that situation you could have done it before with an ANY [ ]. Still, it looks pretty nice.