in reply to Bogus warning for low priority or, or something subtle

This is definitely interesting. I personally never noticed that or actually has a different precedency as ||. I don't like it, and don't think that gives anyone any real benefit.

What was the thinking behind this? My guess is that, they want to give you the feeling that, || is used to connect "fragments" within a "statment", and or is used to conect "statements", sort of treating Perl like a natural language. In this sense, or comes after ||.

  • Comment on Re: Bogus warning for low priority or, or something subtle

Replies are listed 'Best First'.
Re^2: Bogus warning for low priority or, or something subtle
by GrandFather (Saint) on Aug 05, 2005 at 05:14 UTC

    It's so you can:

    my $importantValue = SomethingTricky () or die "A nasty thing happend\ +n";

    Perl is Huffman encoded by design.
Re^2: Bogus warning for low priority or, or something subtle
by mrpeabody (Friar) on Aug 05, 2005 at 05:25 UTC
    This is definitely interesting. I personally never noticed that or actually has a different precedency as ||. I don't like it, and don't think that gives anyone any real benefit.
    The different precedence is the whole point of having two "or" and two "and" operators in the first place. Read perlop under "Logical Or and Exclusive Or".
Re^2: Bogus warning for low priority or, or something subtle
by gellyfish (Monsignor) on Aug 05, 2005 at 14:26 UTC

    The or (and and) was introduced with perl 5.000 as described in the Changes5.0000 :

    New "and" and "or" operators work just like && and || but with a precedence lower than comma, so they work better with list operators.
    The reason that they are separate operator is to ensure "least surprise" and not to break existing code by changing the precedence of the existing operators. I guess it was also considered that it would be more expressive to have the two sets of operators with different precedence.

    I'm sure if you were to send a patch reversing this to p5p it would be given the consideration it deserves.

    /J\

Re^2: Bogus warning for low priority or, or something subtle
by halley (Prior) on Aug 05, 2005 at 14:14 UTC
    I personally never noticed that or actually has a different precedency as ||. I don't like it, and don't think that gives anyone any real benefit.

    Nice attitude. The first time you encounter some feature, you not only dismiss it for yourself, but you dismiss it for everyone. Stop and think about something for its benefits before you write such a blanket statement about "anyone."

    --
    [ e d @ h a l l e y . c c ]