[Edu-sig] re: None potato, one potato, two potato, more..

Kirby Urner urnerk at qwest.net
Thu Jan 1 19:48:11 EST 2004


> 
> >>> 16**3/4
> 1024.0
> 
> Which is clearly not the answer I am expecting
> 

Fits my expectations.  16**3 is "one thing" and /4 comes after.  So I see
that as (16*16*16)/4.  I guess I must parse the way Python does.

> second try:
> 
> >>> 16**(3/4)
> 8.0
> 
> Which is.
> 
> And I am sure long debates could ensue about which is more intuitive and
> whether the language could be improved by adjusting the parser to
> recognize what I meant in try one, i.e. adjust the operator precedence 
> order.

Exponentiation has higher precedence in all languages that I know about,
where precedence is used at all (it's not used in J).  It has higher
precedence in ordinary math notation too, but the superscript notation
resolves a lot of the ambiguity even without parentheses.

More likely to trip people up (or did me) is:

  >>> -1**2
  -1

As a unary operator, - has less precedence than **.

> But my second try is good enough for me, and I now know the rules for my
> 3rd to 3 millionth try.  The burden now is where it rightly belongs, with
> me.

We agree here.  You encounter a language, you learn its quirks (or accept
them as perfectly normal as the case may be) and move on.  Everyday math
notation has its own quirks and weirdnesses.  Nothing is above criticism.

> And if I choose to give up programming in disgust with the fact it took me
> two tries - well that's up to me.
> 

We agree again.

> But Guido can relax and enjoy his New Year, I hope.
> 
> Art

Maybe you say "but" because you believe Guido is afraid of ever losing a
beginner and thinks his job is to bend over backwards to accommodate them.  

Just guessing.  I don't really know why you say "But".

Kirby





More information about the Edu-sig mailing list