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

Discussion in 'Python' started by Esmail, Nov 30, 2009.

  1. Esmail

    Esmail Guest

    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
     
    Esmail, Nov 30, 2009
    #1
    1. Advertising

  2. Esmail

    Lie Ryan Guest

    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.
     
    Lie Ryan, Nov 30, 2009
    #2
    1. Advertising

  3. Esmail

    MRAB Guest

    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).
     
    MRAB, Nov 30, 2009
    #3
  4. In article <>,
    Ben Finney <> wrote:
    >Lie Ryan <> 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
     
    Albert van der Horst, Dec 6, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=

    it's all about semantics

    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=, Jul 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    343
    =?Utf-8?B?RGltaXRyaXMgUGFudGF6b3BvdWxvcw==?=
    Jul 14, 2004
  2. Luigi Donatello Asero

    Semantics extractor

    Luigi Donatello Asero, Feb 14, 2004, in forum: HTML
    Replies:
    5
    Views:
    552
    Eric Bohlman
    Feb 14, 2004
  3. Esmail
    Replies:
    2
    Views:
    294
  4. Esmail
    Replies:
    6
    Views:
    295
    inhahe
    Nov 30, 2009
  5. Jon
    Replies:
    3
    Views:
    230
    Ray at
    Oct 29, 2003
Loading...

Share This Page