Juerd wrote:
There will always be various control constructs that cannot be written as an equivalent function. Otherwise, there is no way to write the higher level ones.Assuming the following are true:
A: "if" is now a normal function
B: "foo() + 3" is (foo) + 3, foo doesn't get 3.
Then does that mean we're stuck with:
C: "if($foo) { say 'foo' }" being a syntax error?
I currently think A is wrong. Am I right?
Juerd
I suspect that "goto" and "if" are on this list. Possibly they are the only things on this list, but "return" is a strong contender.
Additionally, any predicate form cannot be a "normal function". You might be able to define an &infix:<for>, but getting to where you don't need the {}'s on the LHS block, and getting a proper list on the RHS gets rather abnormal.
Something that crossed my mind while writing this: Does
for { say } <== @a;
Work?
-- Rod Adams