Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 32,023 of 33,346    |
|    Seungbeom Kim to Zeljko Vrba    |
|    Re: why not implicit operator !=()?    |
|    17 Mar 12 05:15:43    |
      From: musiphil@bawi.org              On 2012-03-16 06:31, Zeljko Vrba wrote:       > Using << for stream output is, IMO, bad form too, and was an       > extremely bad idea when streams were designed. The notation is       > severely misleading as it implies sequencing where there is none. I       > have been bitten numerous times by something looking as innocuous as       > cout << a() << b() << endl; but where a and b had some side-effects.       > This looks like sequencing, but is in actuality a series of function       > calls with unspecified order of evaluation with no sequence point in       > between. Bad notation indeed.              The unspecified order of evaluation is a common thing in C++ that       programmers should be aware of, and it is a bad practice to combine       side effects (order-sensitive ones, especially) with printing, anyway.       (It's analogous to putting a mutating operation inside an assert().)       So I don't think the problem lies in the notation.              > This       >       > cout , a() , b() , endl;       >       > looks possibly a bit uglier, but it would ensure proper sequencing.              I would say that's much more dangerous than overloading '<<'. '<<' was       a new application to streams, so introducing the overloaded '<<'       didn't change the meaning of existing programs. However, it's not the       case for ',' which has had an established meaning for all types of       expressions, so assigning a new meaning to it would create a big       confusion.              --       Seungbeom Kim                      [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca