Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bo Persson Newsgroups: comp.lang.c++ Subject: Re: rational numbers Date: Tue, 21 Sep 2021 09:08:14 +0200 Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net kfCHXgtf470hdOhk5Qc/wAxWDY4AwPY426MZOFpO1gpCT8ro9s Cancel-Lock: sha1:xfB3o3mRr7Qj9rJsBiJOeoc5qBE= User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Language: sv Xref: csiph.com comp.lang.c++:81362 On 2021-09-20 at 22:38, Bart wrote: > So I'm judging how conveniently the language allows me to do that simple > task. I don't care what else cout might do for me in that context. > > Here, anyone can judge for themselves (although I doubt they'll be that > open minded in a C++ group): > >   20 print i, sqr(i) > >   std::cout << i << " " << sqrt(i) << std::endl; > > The first line is from decades-old BASIC. The second line, which also > needs iostream and math.h includes, is from latest C++. > >> Any print system has its advantages and disadvantages.  You should be >> able to understand that.  Instead, you'd rather assume that because it >> is C++, it is necessarily all bad without any need for further thought >> or knowledge. > > As I said above, people can make up their own minds. Personally I find > the first type considerably easier to write, and to read. The only > difficulty is having to go and find out how to suppress the automatic > space between items, and the newline at the end. > Yes, the BASIC print works well for built in types, but how do you extend it to works with user defined types? Wait, in BASIC that is not a problem (you just don't allow user defined types :-). I have seen the same feature in Pascal, where READ and WRITE worked similarly well, for the built in types. I looked long and hard for the way to output one of my records - only to find that you could not. Still remember how disappointed I was - a nice language feature that only worked for some simple types, but not for the types I actually used in the program. See "useless".