Austin Hastings wrote:
?& ?| ?^ - [maybe] C-like bool operations
?&= ?|= ?^= - (result is always just 1 or 0)
[?&] [?|] [?^] - (hyperversions)
[?&]= [?|]= [?^]=
[?&=] [?|=] [?^=]
Two possible differences between double-[&|] and single-[&|]:
1- Force (unlazy) evaluation of all operands.
2- Force conversion to 1 or 0. (Are "true" and "false" going to be
built-in literals, a la java?)
Which (or both) of these are supposed to come from the single-op
versions of these?
Superpositions don't lazily evaluate their operands (unless those
operands are themselves superpositions).
And they certainly don't convert to binary.
Since the flexprs haven't collapsed, what interactions are there when
"appending" to them?
$a = 1 | 5;
$a &= 10;
C<&> is higher precedence that C<|> so...
What's $a?
1 | 5 & 10
Yes (by precedence)
(1|5) & 10
Yes (explcitly).
(1&10) | (5&10) ?
Yes (by the rules of boolean algebra)
On the other hand, some of the examples seem counterintuitive. That is,
considering Damian's:
$seen = $start | $finish;
for ... -> $line {
print "$line\n" unless $line == $seen;
$seen |= $line;
}
I can understand the notion of "unless $line is a-or-b-or-c-or..." but
I keep THINKING in terms of "I've seen a-and-b-and-c-and..."
That's understandable. So you write:
$seen = $start & $finish;
for ... -> $line {
print "$line\n" if $line != $seen;
$seen &= $line;
}
So when would multiple flexops be combined? Anyone have any real world
examples, even simple ones?
Sure (for sufficiently complex values of simple ;-)
Here's how to find the love of your life:
$requirements = "tall" & "dark & "handsome"
| "old" & "rich"
| "Australian";
for <> -> $candidate {
my $traits = any( split /<ws>/, $candidate );
print "True love: $candidate\n"
if $requirements eq $traits;
}
Of course, not everyone can hope to be lucky enough to meet an Australian,
but you get the idea. ;-)
Damian