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,847 of 33,346    |
|    Bart van Ingen Schenau to Zeljko Vrba    |
|    Re: iostream replacement    |
|    02 Feb 13 05:22:19    |
      From: bart@ingen.ddns.info.invalid              On Fri, 01 Feb 2013 10:01:02 -0600, Zeljko Vrba wrote:              > I'm bashing iostreams in particular because they overload arithmetic       > operators to have implicit side-effects. IMO, side-effects and       > unspecified order of evaluation don't mix well. I wonder whether K&R       > would have been so lax with evaluation order had they forseen the       > possibility of overloading which introduces side-effects.              I don't see what Kernighan and Ritchie have to do with it.       If an ancestor language leaves something unspecified (such as order of       evaluation in C), there is nothing stopping the designer of a derived       language from pinning it down, even if the derived language must be       mostly backwards compatible with the ancestor language (as with C++ and       C).              >       > What iostreams *should* have done was something akin to       >       > cout.print(a).print(modify(b)).print(b).endl();       >       > More verbose than chained << but still shorter than              It is more verbose and does not give you any additional guarantees.       In particular, there are absolutely no guarantees about the sequencing       between `modify(b)` and `b` in the later print call.       Those chained method calls are exactly equivalent to        cout << a << modify(b) << b << endl;              which (for int a,b;) is identical to        cout.operator<<(a).operator(modify(b)).operator<<(b).operator<<(endl);              >       > cout << a;       > cout << modify(b);       > cout << b;       > cout << endl;       >       > and with the same sequencing guarantee.              No, that is not true. Chaining function calls does not give any       sequencing guarantee on the evaluation of the function parameters, not       even between the parameters for different functions.               |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca