>> foo: does [print "Hi"]
== make action! [[] [...]]
>> loop 3 :foo
Hi
Hi
Hi
Also, (the recent change to the loop protocol made more looping constructs accept action!s). It has been intended that any "branch" slot which would accept a block would also accept an action!, just a matter of doing it.
The more interesting feature of branches as functions is when they get an argument. ALSO, which runs whenever its left hand side is not null, will pass any arity-1 function what it got:
>> case [
1 > 2 [10]
1 < 2 [20]
] also :print
20
You can create functions on the spot with lambda (infix form, =>)
>> case [
1 > 2 [10]
1 < 2 [20]
] also val => [
print ["A branch in the case ran and gave" val]
]
A branch in the case ran and gave 20
This is supposed to be systemic. So IF itself works this way.
>> data: [a 10 b 20]
>> if try select data 'b
val => [print ["If selected a value and it was" val]]
If selected a value and it was 20
Note that infix lambda is variadic, and knows a few tricks:
I think the leaning for lambdas is they...like DOES...will not have a RETURN/LEAVE of their own. So if you say RETURN inside the body of a lambda, you use whatever RETURN was already in effect.
I had a weird idea that you would do multi-arg lambdas with paths:
>> sum2: (a/b => a + b)
>> sum2 10 20
== 30
Saves a little typing...and maybe a little visually tighter than ([a b] => a + b). Cool, or too weird?