On Sun, Sep 14, 2008 at 04:18:44PM +0200, Carl Mäsak wrote:
> Conrad (>):
> > Is there something more up-to-date concerning "Perl 6 best practices" that
> > are presently-recommended (by p6l or @Larry) than the following item on the
> > Perl 6 wiki?
> [...]
> That said, I do have one Perl 6-specific "best practice". I know
> you're looking for a collection, but one's a start. :) Here it is:
> Do not combine 'ne' and '|', like this:
> die "Unrecognized directive: TMPL_$directive"
>    if $directive ne 'VAR' | 'LOOP' | 'IF';
> [...]
> The more general advice, then, would be not to use junctions together
> with negated equality operators. Instead, use the non-negated equality
> operator, and negate the whole expression.

This particular case is explicitly mentioned in S03:2529:

    Use of negative operators with syntactically recognizable junctions may
    produce a warning on code that works differently in English than in Perl.
    Instead of writing
        if $a != 1 | 2 | 3 {...}
    you need to write
        if not $a == 1 | 2 | 3 {...}
    However, this is only a syntactic warning, and
        if $a != $b {...}
    will not complain if $b happens to contain a junction at runtime.

We might be able to craft a similar warning in Rakudo, but I'm
curious to see how/where STD.pm will choose to handle this.
(My guess is it will have something to do with 
infix_prefix_meta_operator:<!>, although we also have to have a way
to handle it for the infix:<!=> and infix:<ne> cases.)


Reply via email to