semantics of ** (unexpected/inconsistent?)

Albert van der Horst albert at spenarnc.xs4all.nl
Sun Dec 6 09:07:55 EST 2009


In article <87eingrbh9.fsf at benfinney.id.au>,
Ben Finney  <ben+python at benfinney.id.au> wrote:
>Lie Ryan <lie.1296 at gmail.com> writes:
>
>> I generally do not expect operator precedence to be reliable at all
>
>Have another read of the thread. The OP's confusion was not over
>operator precedence, but over how names resolve to values in
>expressions.

Operator precedence comes naturally into this matter.
For example, in algol 68 -3**2 is parsed as
  (-3)**2
because of the simple rule that all unary operators have precedence
over all binary operators.

(It is a good rule, and this is about the only way to get a
somewhat surprising result. Unary operators -- as long as they
are always put up front -- need not have
a precedence among themselves, so with this rule they don't
need a precedence full stop. )

>Ben Finney

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst




More information about the Python-list mailing list