Piers Cawley mused:
The idea being that, when you do
a_pure_func($val1|$val2|$val3)
instead of Perl going away and doing the calculation right away, you
get back a 'special' superposition
Remember to s/superposition/junction/g. For this week, at least ;-)
> which stores an 'invocation description' and calculation is deferred
> until you need to get a superposition's list of possible states.
You get most of that with just:
$deferred = &a_pure_func.assuming(arg=>$val1|$val2|$val3);
Then, later, when you want the result junction:
$junction = $deferred();
Of course, the utility of this kind of laziness isn't restricted to
superpositions, so maybe there would be an C<is lazy> property for
subroutines. For example, given the eager subroutine:
sub a_pure_func(Num $n) returns Num {
return $n ** $n
}
we could make it lazy thus:
sub a_pure_func(Num $n) is lazy returns Num {
return $n ** $n
}
which would cause any invocation of C<a_pure_func> to cache
its arguments (probably in a closure) and return a "proxy"
Num that carries out the computation only when the proxy is
evaluated.
Then it wouldn't matter what the subroutine did, or whether
the argument was a simple number, some species of junction,
or some mysterious object of a class derived from Num.
Damian