Pow operator precedence

Stewart Gordon smjg_1998 at yahoo.com
Fri Jan 13 15:21:11 PST 2012


On 13/01/2012 19:14, Manu wrote:
<snip>
> I think there's one very important point to realise in all your examples though...
> We're NOT writing -4x² + 3. We write -4 * x ^^ 2 + 4. That's not a polynomial expressions,
> it's source code.

What are you on about?  -4x² + 3 and -4 * x ^^ 2 + 3 are the exact same polynomial 
expression.  They're just written in different notations.

> I don't know about you, but the visual similarity is just not there for me. I can't see
> C/D/Java/whatever code as a direct transcription of mathematical notation no matter how
> hard I squint at it.
<snip>

But we mathematicians get used to the similarities in stuff like precedence rules.  We 
shouldn't have to remember that D works differently in ways that the compiler won't warn 
us if we forget.  Add to that that some of us may be migrating from something like Maple 
or Mathematica that bridges the gap between mathematical notation and program code.

And my points still apply.

x ^^ 3 - x ^^ 2 + 3
vs.
        - x ^^ 2 + 3

One shouldn't have to remember to add brackets to x ^^ 2 because removal of the x ^^ 3 
term has changed the nature of the -.

Stewart.


More information about the Digitalmars-d mailing list