home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Comma operator for stream I/O (was: Answers on a postcard...)
- Message-ID: <1992Sep15.174644.12710@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Sep13.160033.7735@taumet.com> <4958@holden.lulea.trab.se>
- Date: Tue, 15 Sep 1992 17:46:44 GMT
- Lines: 28
-
- jbn@lulea.trab.se (Johan Bengtsson) writes:
-
- >Since I am also in search of an example where the comma operator would be
- >a good choice:
-
- >Would the comma operator have been a good choice for stream I/O?
- >I.e. instead of the rather hard-to-read expression
-
- > cout << "The value is " << value << endl;
-
- >you would write
-
- > cout, "The value is", value, endl;
-
- >The precedence is just right (very low).
-
- The reason why << and >> are used is historical. Stroustrup explains
- that of the available operators, they seemed to be the best choice.
- At that time (1985), the comma operator could not be overloaded, so
- was not a possibility. Perhaps comma would have been used otherwise.
-
- I've been using << and >> for so long now that I find them easier
- to read than the comma example. I must admit, though, that when I
- started in C++ I found << and >> quite bizarre and unreadable.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-