Damian Conway <[EMAIL PROTECTED]> writes:
> 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;
> }
But given a decent Collection hierarchy:
my $seen = Set.new($start,$finish);
for <> -> $next {
print $next unless $next =~ $seen;
$seen.insert($next);
}
Which is somewhat more explicit about what's going on. But I'll grant
you, the comparator stuff is rather neat...
>> 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.
I think we could really use a 'science fiction' article about
superpositions. Sort of like the Q::S talk, but without the 'in
constant time' jokes.
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?