Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: semantics of ** (unexpected/inconsistent?)

Reply
Thread Tools

Re: semantics of ** (unexpected/inconsistent?)

 
 
Esmail
Guest
Posts: n/a
 
      11-30-2009
Thanks all!! I get it now

It helped to have a number of different explanations, thanks
for taking the time to post. Much appreciated.

Cheers,
Esmail

 
Reply With Quote
 
 
 
 
Lie Ryan
Guest
Posts: n/a
 
      11-30-2009
On 11/30/2009 12:38 PM, Esmail wrote:
> Thanks all!! I get it now
>
> It helped to have a number of different explanations, thanks
> for taking the time to post. Much appreciated.


I generally do not expect operator precedence to be reliable at all
except for:

+ - (binary ops, not the unary)
* /
**

for other operators I would have explicit parens. It's too much work to
remember the rest of the precedence sheet.
 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      11-30-2009
Lie Ryan wrote:
> On 11/30/2009 12:38 PM, Esmail wrote:
>> Thanks all!! I get it now
>>
>> It helped to have a number of different explanations, thanks
>> for taking the time to post. Much appreciated.

>
> I generally do not expect operator precedence to be reliable at all
> except for:
>
> + - (binary ops, not the unary)
> * /
> **
>
> for other operators I would have explicit parens. It's too much work to
> remember the rest of the precedence sheet.


Most programming languages don't differentiate in text between the
number "negative 3" and the expression "negated 3". APL does. The former
is written as "¯3" (3 preceded by the overscore character) and the
latter as "-3" (3 preceded by the minus sign).
 
Reply With Quote
 
Albert van der Horst
Guest
Posts: n/a
 
      12-06-2009
In article <(E-Mail Removed)>,
Ben Finney <(E-Mail Removed)> wrote:
>Lie Ryan <(E-Mail Removed)> 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@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
it's all about semantics =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?= ASP .Net 2 07-14-2004 08:19 AM
Semantics extractor Luigi Donatello Asero HTML 5 02-14-2004 07:10 PM
Equivalency Semantics, Operator Overloading Grant Austin C++ 3 12-09-2003 05:03 PM
std::vector<>::clear semantics Stefan Höhne C++ 10 10-17-2003 09:50 AM
destructor / semantics of delete this Alexander Stippler C++ 6 08-20-2003 03:27 PM



Advertisments