Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: Operator Precedence (unary negation and exponentiation)

by pdcawley (Hermit)
on Jan 19, 2003 at 02:17 UTC ( [id://228108]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Operator Precedence (unary negation and exponentiation)
in thread Operator Precedence (unary negation and exponentiation)

Hold on just a moment. One minute you're arguing that Perl's operator precedence should be altered so that it agrees with your flawed understanding the normal order of operations, the next you're arguing that I'm wrong because that's not how Perl's operator table looks? You really can't have it both ways you know.

Go check any mathematical reference on this, here is pretty much the first explanation that fell off a google search for 'normal order of operation'.

  • Comment on Re: Re: Re: Operator Precedence (unary negation and exponentiation)

Replies are listed 'Best First'.
Re: Re: Re: Re: Operator Precedence (unary negation and exponentiation)
by Elliott (Pilgrim) on Jan 23, 2003 at 01:55 UTC
    Actually I wasn't arguing either of those things (though I insist on my right to hold contradictory opinions!)

    I asked why Perl's order of operations does not match my intuition. The answer "negation = subtraction" might explain my failure of intuition but does not explain anything about Perl because Perl does not treat them as the same.

    Thank you for the link. The essay made sense - though it still feels counter-intuitive to me.

      One of the most important parts of learning to do maths (and, as a mathematician I could, if pressed, put up a reasonable argument that programming is just another branch of maths) properly is the process of training your intuition -- usually by checking your intuition at the door and working through stuff step by step until you learn why your intuition was correct (or, rarely, incorrect). Probability theory is the classic area where almost every non-trivial result seems counter intuitive.

      Coming back to this particular thing, negation is not quite the same as subtraction, it is a shorthand for it, and there is a right and a wrong time to expand it. For instance, it's perfectly valid to write 3 * -2. If Perl didn't treat negation as somehow 'special' then that would be a syntax error.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://228108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found