Is there any way to write a user-defined operator so that it
short-circuits, like && and || ? This might be function trait, for
instance,
sub infix:!! ($lhs, $rhs) is short_circuit {...}
Alternatively, there might be a new parameter type that indicates that the
parameter is not evaluated immediately:
sub infix:!! ($lsh, $rhs is deferred) {...}
In this case, it might be possible to make ordinary functions
short-circuit also
sub conditional(bool $condition, $trueCase is deferred, $falseCase is
deferred)
{
return ($condition) ?? $trueCase :: $falseCase;
}
I have no idea how difficult it would be to implement either of these
concepts. Also, if a parameter is deferred, would we need a new keyword to
say when to actually evaluate it?
Joe Gottman