python: bug or feature?

Grant Edwards nobody at nowhere.nohow
Thu Aug 10 22:14:25 EDT 2000


In article <slrn8p6bns.129.hzhu at rocket.knowledgetrack.com>, Huaiyu Zhu wrote:
>On Thu, 10 Aug 2000 19:34:27 GMT, Grant Edwards <ge at nowhere.none> wrote:
>>>I understand why they might need a different level from logical operators.
>>>But why not just one bitwise level?
>>
>>Surely you're joking?
>
>I'm not.  Perhaps just because I'm one exception to "everybody".  :-)
>
>If you ask _everybody_ here what's the expected symbols and precedences of
>bitwise operators without checking the docs, only _some_ would give correct
>answers.  I'll keep to myself a guess of what the proportion is.

I'm sure my perception is different that some.  I spent a semester or two
studying boolean algebra and expect boolean expressions to work the standard
way most people expect arithmetic expressions to work. Since then, I've been
doing embedded software and device drivers for 15 years and use bitwise
operators constantly.  I'm sure there are a lot of people who don't know
that "and" has higher precedence that "or".

>And does years of experience with other languages makes it a good choice for
>python?  What about pointers, goto, etc?

If we're simplifying, then hadn't we'd better eliminate _all_ operator
precedence? Having "standard" precedence for arithmetic operators but not
for bitwise boolean operators just seems like a huge irregularity in the
language. Besides, there are probably a lot of people who don't know the
precedence of multiply and addition.

If you want to eliminate all operator precedence and do strictly
left-to-right grouping, or prefix, or postfix, or whatever, that's fine with
me, but I think it needs to be consistent throughout the language for all
operators.

><philosophical rambling>
>Computer languages are more like engineering than science in that a lot of
>things depend on practical feasibility and convenience.  Years of experience
>could be abandoned outright if a better technology comes up.
></philosophical rambling>

Sure. I've used various other "technologies" for expressions (prefix,
postfix, infix with no precedence, whatever-you-call-what-Smalltalk-uses).
Pick one. It's OK with me. But, if we're going to have "standard" prececence
for some sets of operators, we ought to go by the standard for all sets.

I think that "*" having higher precidence than "+" but having "&" and "|"
the same violates the "rule of least surprises".

-- 
Grant Edwards                   grante             Yow!  I want EARS! I
                                  at               want two ROUND BLACK
                               visi.com            EARS to make me feel warm
                                                   'n secure!!



More information about the Python-list mailing list