[EMAIL PROTECTED] wrote:
Uh, I'm not sure this does what I think you wanted to say it does. ;) $x is a boolean, unless < returns a magical object... in which case, the magical part of $x ought to be a reference to the original $j, no?Well, we see the same kind of thing with standard interval arithmetic:
(-1, 1) * (-1, 1) = (-1, 1) (-1, 1) ** 2 = [0, 1)
The reason that junctions behave this way is because they don't collapse. You'll note the same semantics don't arise in Quantum::Entanglement (when you set the "try to be true" option).
But you can force a collapse like this:
my $x = 4 < $j;
if $j < 2 { say "never executed" }
By which I mean:
my $x = 4 < $j; if $x < 2 { say "never executed" }
Well, I suspect that junctions will have to be references and just collapse every time. Observe:I'm wonding if we should allow a method that returns a junction that is allowed to collapse the original:
if 4 < $j.collapse and $j.collapse < 2 { say "never executed"; }
But that's probably not a good idea, just by looking at the
implementation complexity of Quantum::Entanglement. People will just
have to learn that junctions don't obey ordering laws.
my $x = any(1, 2, 3, 4, 5); print "SHOULD NOT RUN" if (is_prime($x) && is_even($x) && $x > 2);
This only works if $x collapses. Same for matching junctioned strings:
my $a = any (<a b c>); print "Boo!" if $a ~ /a/ and $a ~ /b/ and $a ~ /c/;
(perhaps I meant to use ~~, I don't quite remember :) )
Either way, autocollapsing juntions is a Good Thing IMHO, and the only remaining confusion (to go back to my initial post) is that the only case that doesn't work is when you instance a junction twice as a pair of same literals:
print "SUCCESS, unfortunately" if (is_prime(any(1, 2, 3, 4, 5)) && is_even(any(1, 2, 3, 4, 5)) && any(1, 2, 3, 4, 5) > 2);
Hope I'm making sense. Been a hard day at work. ;)
Miro