So here is a weird idea that was once a feature of MATCH itself:
match+: reframer func [f [frame!]] [
eval f else (^e -> [return null])
return ^f.1
]
>> match+ even? 10 + 20
== 30
>> match+ even? 1 + 2
== \~null~\ ; antiform (logic!)
>> match+ parse "aaa" [some "a"]
== "aaa"
>> match+ parse "aaa" [some "b"]
== \~null~\ ; antiform (logic!)
- It builds a FRAME! for a function call (but doesn't run it yet)
- Then it runs the function
- If the function returns null/void/ERROR! then it returns null
- Otherwise it returns the first argument to the frame
"Cool! Why Isn't It Built In To MATCH?"
The main thing is that I'm not quite sure what to do about infix in these kinds of constructs:
match+ parse "aab" [some "a"] else [print "what should this do?"]
We know what's most useful... which is to model (match+ parse) as a "compound function"
>> match+parse "aab" [some "a"] else [print "should run"]
should run
>> match+parse "aaa" [some "a"] else [print "should not run"]
== "aaa"
But the "rhythm" of deferred infix that one has learned is that it defers one lookback (e.g. ELSE doesn't take the BLOCK! behind it) but only one. Then a function runs.
When they are two words...they look like two functions. So I've been hesitant to introduce behavior that doesn't obey the rhythm.
![]()