Piers Cawley wrote:
Whilst I don't wish to get Medieval on your collective donkey I must
say that I'm really not sure of the utility of the proposed infix
superposition ops. I'm a big fan of any/all/one/none, I just think
that
one(any($a, $b, $c), all($d, $e, $f))
Is a good deal more intention revealing than the superficially
appealing than
($a & $b & $c) ^ ( $d | $e | $f )
I very much doubt that most people will write either of those.
I suspect it will be quite unusual to see nested superpositions
in code. Most folks are going to be using them for simple but
very common checks like:
if ( $start & $finish < 0 } {
($finish,$start) = [-]($start,$finish); # hyper negate
}
if ( $start | $finish < 0 ) {
print "Bad index\n" and die;
}
given $start {
when 1|3|5|7|9 { print "That's odd...\n" }
when 2|4|6|8|10 { print "Even so...\n" }
default { print "Taking off shoes...\n" }
}
my $seen = $start | $finish;
for <> -> $next {
print $next unless $next == $seen;
$seen |= $next;
}
which takes rather more decoding. And if you *do* want to use such
operators, surely you could just do
use ops ':superpositions';
in an appropriate lexical scope. Am I missing something?
Yes. That superpositions are going to be so widely used once people
catch on, that users going to curse us every time they have to
write C<use ops ':superpositions';> at the start of every scope.
;-)
Damian