Jonas Liljegren wrote:
> Does any other RFC give the equivalent to an 'in' operator?
>
>
> I have a couple of times noticed that beginners in programming want to
> write if( $a eq ($b or $c or $d)){...} and expects it to mean
> if( $a eq $b or $a eq $c or $a eq $d ){...}.
>
> I think it's a natural human reaction to not be repetative. An 'in'
> operator will help here. It could be something like this:
>
> $a in @b; # Has @b any element exactly the same as $a
>
> $a == in @b; # Is any element numericaly the same as $a
> $a eq in @b;
> $a > in @b; # Is $a bigger than any element in @b?
> $a not in @b; # Yes. Make 'not' context dependent modifier for in.
> ...
>
> You could even use it as a version of the ||| operator. :-)
> $a = in @b; # Assign the first defined value to $a
>
Quantum::Superpositions provides this in a more flexible way by adding the
'any' and 'all' keywords.
<http://search.cpan.org/doc/DCONWAY/Quantum-Superpositions-1.03/lib/Quantum/
Superpositions.pm>
One of Damian Conway's many promised RFCs will cover incorporating these
ideas into Perl 6.