Re: Overriding logical operators?

Discussion in 'Python' started by Terry Reedy, Aug 21, 2004.

  1. Terry Reedy

    Terry Reedy Guest

    "Andrew Durdin" <> wrote in message
    news:...
    > I noticed that, although there are special methods for most operators,
    > they are conspicuously absent for the logical "or" and "and". I'm
    > guessing that the reason for this is that these operators
    > short-circuit if their first operand answers the whole question?


    If you think of a op b as being an alternate, abbreviated syntax for the
    function call op(a,b), then short-circuiting 'and' and 'or' are not really
    operators. Various Lisp dialects have various terms, such as 'special
    form' for syntax that looks like a normal function call but isn't. I think
    we need a special term in Python also, such as 'pseudo-op' or 'syntax
    operator' to flag 'and' and 'or' as importantly different from regular
    operators.

    Terry J. Reedy
     
    Terry Reedy, Aug 21, 2004
    #1
    1. Advertising

  2. Terry Reedy

    Greg Ewing Guest

    Terry Reedy wrote:
    > I think
    > we need a special term in Python also, such as 'pseudo-op' or 'syntax
    > operator' to flag 'and' and 'or' as importantly different from regular
    > operators.


    They're really control structures, like 'if' and 'while'.
    The fact that they happen to look a bit like operators is
    purely coincidental...

    --
    Greg Ewing, Computer Science Dept,
    University of Canterbury,
    Christchurch, New Zealand
    http://www.cosc.canterbury.ac.nz/~greg
     
    Greg Ewing, Aug 24, 2004
    #2
    1. Advertising

  3. Terry Reedy

    Terry Reedy Guest

    "Greg Ewing" <> wrote in message
    news:...
    > Terry Reedy wrote:
    > > I think
    > > we need a special term in Python also, such as 'pseudo-op' or 'syntax
    > > operator' to flag 'and' and 'or' as importantly different from regular
    > > operators.

    >
    > They're really control structures, like 'if' and 'while'.
    > The fact that they happen to look a bit like operators is
    > purely coincidental...


    Ok, I'll think of them as 'control words' for now.

    tjr
     
    Terry Reedy, Aug 24, 2004
    #3
    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. Andrew Durdin

    Overriding logical operators?

    Andrew Durdin, Aug 21, 2004, in forum: Python
    Replies:
    3
    Views:
    422
    Michael Hudson
    Aug 23, 2004
  2. Andrew Durdin

    Fwd: Overriding logical operators?

    Andrew Durdin, Aug 21, 2004, in forum: Python
    Replies:
    1
    Views:
    346
    Greg Ewing
    Aug 24, 2004
  3. Andrew Durdin

    Re: Overriding logical operators?

    Andrew Durdin, Aug 21, 2004, in forum: Python
    Replies:
    1
    Views:
    377
    Oliver Fromme
    Aug 23, 2004
  4. August Karlstrom

    Precedence of Logical Operators

    August Karlstrom, Nov 20, 2005, in forum: C Programming
    Replies:
    25
    Views:
    814
    August Karlstrom
    Nov 23, 2005
  5. Replies:
    7
    Views:
    488
    Mike Treseler
    Jul 12, 2007
Loading...

Share This Page