OT Signature quote [was Re: Unrecognized escape sequences in string literals]

Dave Angel davea at ieee.org
Fri Aug 14 22:25:18 EDT 2009


Benjamin Kaplan wrote:
> On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan <darkwater42 at gmail.com>wrote:
>
>   
>> P.S. Overloading "left shift" to mean "output" does indeed seem a bit
>> sketchy, but in 15 years of C++ programming, I've never seen it cause
>> any confusion or bugs.
>>     
>
>
>
> The only reason it hasn't is because people use it in "Hello World". I bet
> some newbie C++ programmers get confused the first time they see << used to
> shift.
>
>   
Actually, I've seen it cause confusion, because of operator precedence.  
The logical shift operators have a fairly high level priority, so 
sometimes you need parentheses that aren't obvious.  Fortunately, most 
of those cases make compile errors.


C++ has about 17 levels of precedence, plus some confusing associative 
rules.  And operator overloading does *NOT* change precedence.

DaveA




More information about the Python-list mailing list