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

Douglas Alan darkwater42 at gmail.com
Fri Aug 14 12:42:15 EDT 2009


On Aug 14, 12:17 pm, Grant Edwards <invalid at invalid> wrote:

> On 2009-08-14, Steven D'Aprano <st... at REMOVE-THIS-cybersource.com.au> wrote:

> > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote:

> >> "I saw `cout' being shifted "Hello world" times to the left and stopped
> >> right there."  --Steve Gonedes
>
> > Assuming that's something real, and not invented for humour, I presume
> > that's describing something possible in C++. Am I correct?
>
> Yes.  In C++, the "<<" operator is overloaded.  Judging by the
> context in which I've seen it used, it does something like
> write strings to a stream.

There's a persistent rumor that it is *this* very "abuse" of
overloading that caused Java to avoid operator overloading all
together.

But then then Java went and used "+" as the string concatenation
operator. Go figure!

|>ouglas

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.




More information about the Python-list mailing list