Re: We have a new standard!

Liste des GroupesRevenir à cl c++ 
Sujet : Re: We have a new standard!
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c++
Date : 02. Jan 2025, 17:54:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vl6gbr$3e4rd$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 02/01/2025 15:07, Muttley@DastardlyHQ.org wrote:
On Thu, 2 Jan 2025 13:51:53 +0100
David Brown <david.brown@hesbynett.no> wibbled:
On 02/01/2025 10:23, Muttley@dastardlyhq.com wrote:
Now maybe, but when the language was new I don't see the problem in
creating new
operators specifically for I/O. After all, he had to create new keywords so
why not operators?
>
C++ added "::", ".*" and "->*" early on, and C++20 added <=>.  (There
are also some new non-punctuation operators - like "new".)  Adding new
operators is certainly something that was done, but not done lightly.
 When the language is first created thats irrelevant. You add what you need
to add.
Agreed.

Overloading << and >> was unnecessary and confusing.
Disagreed.  I really don't think it was problematic.  Nor did any of the /many/ people who were involved in the design of C++.  Remember, the language and library has always been discussed, prototyped, and tested by lots of people before being released.  Stroustrup was the main language designer, but he was far from alone.
Over the decades, C++ programmers have had plenty of complaints about the iostreams library.  While it is true that some people complain about the operators used, I don't believe it is the main complaint.

 
cout << 0xFF << 2 << 1234;
>
That doesn't require brackets (unless you are a fan of smart-arse
obfuscated code, and really wanted "cout << (0xff << 2) << 1234;").
 So adding brackets to differential shift from stream I/O is obfuscating is it?
The meaning of "cout << 0xFF << 2 << 1234;" is obviously a chain of outputs - output 0xff, output 2, output 1234.  Regardless of the precedences of operators or what operators are used, the only reason to write code that tries to use a chain of operators for something other than the obvious meaning is to try to look smart.
So "cout << 0xFF << 2 << 1234;" does not require brackets - it does what it appears to do.
If you had intended that the bit "0xff << 2" was to be evaluated as a shift, then you /do/ need parenthesis.  And unless you were trying (and failing) to look smart, you would use them even if the output used "<=" - or "<<<", or a dedicated new Unicode symbol like "⬱".

 
cout <= OxFF << 2 <= 1234;
>
is a lot clearer and doesn't.
>
It is not a lot clearer - it is no clearer at all.  If someone wrote
 Its far clearer and you're just arguing for the sake of it. Extending your
logic why not just have one operator that does everything which varies with
context?
 
That's not "extending" my logic - it is simply failing to understand it.   I didn't suggest that "cout << 0xFF << 2 << 1234;" was clearer than "cout <= 0xFF << 2 <= 1234;" if you wanted the shift operation - I said they are /both/ unclear.
Clarity is, of course, a matter of opinion - and your opinions on code clarity may differ from mine.  But please try to understand what I write.

that (in a parallel universe where <= was used for output streams), I'd
ask two questions.  First, is it a typo and the programmer meant to use
"<=" instead of "<<" ?  Secondly, I'd wonder what the *beep* the
programmer had intended at all, typo or not.
 Now you're trolling.
 
No.
Can you give any kind of realistic situation where you'd want to write code like this?  No, neither can I.  When someone writes code that has no clear purpose, the natural think is to question it.

According to "The Design and Evolution of C++", Unix redirection
operators were a major inspiration for the choice of << and >>.
 Perhaps they shouldn't have been. Perl munged shell and C style syntax and
look what a mess that turned out to be.
 
You wondered about the reasoning for the choices, I told you the reasoning.

Why would it?
>
>
It would be a significant change to the syntax and grammar of the
language, complicating parsing, analysis and compilation.  And they
 Huh? How would it make parsing MORE complicated? Have you ever written a
parser?
I haven't written a C++ parser.  But I believe (because I naïvely belief some things I have read on the internet without checking them) that it is impossible to make a parser for Raku (né Perl) that can parse all correct Perl code - and that key to this is the fact that you can define your own operators in Perl.
(Adding specific fixed operators would be a different matter.)

 
being very subjective.  You have said before (and not without reason)
that C++ can be hard to learn.  A plethora of new operators would not help.
 Having specific operators for specific tasks would actually make it easier
to learn and read in the same way having specific keywords for specific
tasks does. C++ problems due to arn't too many operators.
 
I agree that C++ does not have a problem of having too many operators - but if there were a free-for-all to define operators, then I think that /would/ become a problem.  A few more might be okay, but not too many - and I really don't think input and output needs dedicated operators.

Presumably this is what the new print() and println() functions will do
except they seem to be using python style formatters for [reasons].
>
>
A key point is that the format string should never have to have
information about the type of the operands - thus it is type-safe
 It wouldn't need to. A particular formatter could just call some default
object output method just like streams do.
 
Could this all have been done from the start of C++?  In theory, yes -
 Thats when I'm refering to.
 
in practice no.  std::format and std::print rely on various modern C++
features, such as compile-time evaluation of functions, and are
 Umm, you do realise most compilers already do compile time analysis of
printf formatters otherwise they wouldn't be able to give warnings about
invalid types being passed.
 
Yes - they do /now/.  But they did not do so previously.  And the compiler-specific warning checks on printf-style functions is a very fragile solution, and depends on close matches between the compiler and the printf implementation.  It is not extendable to different types.

Date Sujet#  Auteur
27 Dec 24 * We have a new standard!125Stefan Ram
28 Dec 24 +* Re: We have a new standard!40Sam
28 Dec 24 i+- Re: We have a new standard!1Chris M. Thomasson
28 Dec 24 i`* Re: We have a new standard!38Muttley
28 Dec 24 i +* Re: We have a new standard!26David Brown
29 Dec 24 i i`* Re: We have a new standard!25Muttley
29 Dec 24 i i `* Re: We have a new standard!24David Brown
29 Dec 24 i i  +* Re: We have a new standard!8Muttley
30 Dec 24 i i  i`* Re: We have a new standard!7David Brown
30 Dec 24 i i  i `* Re: We have a new standard!6Muttley
30 Dec 24 i i  i  `* Re: We have a new standard!5David Brown
30 Dec 24 i i  i   `* Re: We have a new standard!4Muttley
31 Dec 24 i i  i    +- Re: We have a new standard!1James Kuyper
1 Jan 25 i i  i    `* Re: We have a new standard!2Michael S
1 Jan 25 i i  i     `- Re: We have a new standard!1Muttley
29 Dec 24 i i  +* Re: We have a new standard!12Paavo Helde
29 Dec 24 i i  i+* Re: We have a new standard!5Michael S
30 Dec 24 i i  ii`* Re: We have a new standard!4Tim Rentsch
30 Dec 24 i i  ii `* Re: We have a new standard!3boltar
30 Dec 24 i i  ii  +- Re: We have a new standard!1David Brown
31 Dec 24 i i  ii  `- Re: We have a new standard!1Tim Rentsch
30 Dec 24 i i  i`* Re: We have a new standard!6Tim Rentsch
30 Dec 24 i i  i +- Re: We have a new standard!1David Brown
31 Dec 24 i i  i `* Re: We have a new standard!4Chris M. Thomasson
31 Dec 24 i i  i  `* Re: We have a new standard!3Tim Rentsch
31 Dec 24 i i  i   `* Re: We have a new standard!2David Brown
31 Dec 24 i i  i    `- Re: We have a new standard!1Chris M. Thomasson
30 Dec 24 i i  `* Re: We have a new standard!3Michael S
30 Dec 24 i i   `* Re: We have a new standard!2David Brown
4 Jan 25 i i    `- Re: We have a new standard!1Michael S
28 Dec 24 i `* Re: We have a new standard!11Phillip
29 Dec 24 i  `* Re: We have a new standard!10Muttley
29 Dec 24 i   `* Re: We have a new standard!9Sam
29 Dec 24 i    +* Re: We have a new standard!4wij
29 Dec 24 i    i`* Re: We have a new standard!3Muttley
29 Dec 24 i    i `* Re: We have a new standard!2wij
29 Dec 24 i    i  `- Re: We have a new standard!1Muttley
29 Dec 24 i    `* Re: We have a new standard!4Muttley
29 Dec 24 i     `* Re: We have a new standard!3Sam
29 Dec 24 i      +- Re: We have a new standard!1Muttley
29 Dec 24 i      `- Re: We have a new standard!1Michael S
28 Dec 24 +* Re: We have a new standard!9Benutzer Eins
28 Dec 24 i`* Re: We have a new standard!8Chris Ahlstrom
28 Dec 24 i +* Re: We have a new standard!6Lynn McGuire
28 Dec 24 i i`* Re: We have a new standard!5Lynn McGuire
29 Dec 24 i i `* Re: We have a new standard!4Chris M. Thomasson
29 Dec 24 i i  `* Re: We have a new standard!3Lynn McGuire
29 Dec 24 i i   +- Re: We have a new standard!1Chris M. Thomasson
29 Dec 24 i i   `- Re: We have a new standard!1Chris M. Thomasson
29 Dec 24 i `- Re: We have a new standard!1David Brown
1 Jan 25 +* Re: We have a new standard!72Michael S
1 Jan 25 i+* Re: We have a new standard!56Muttley
1 Jan 25 ii+- Re: We have a new standard!1Ross Finlayson
2 Jan 25 ii+* Re: We have a new standard!50David Brown
2 Jan 25 iii+* Re: We have a new standard!47Muttley
2 Jan 25 iiii`* Re: We have a new standard!46David Brown
2 Jan 25 iiii +* Re: We have a new standard!42Muttley
2 Jan 25 iiii i`* Re: We have a new standard!41David Brown
2 Jan 25 iiii i +* Re: We have a new standard!10Muttley
2 Jan 25 iiii i i`* Re: We have a new standard!9Keith Thompson
3 Jan 25 iiii i i `* Re: We have a new standard!8Muttley
3 Jan 25 iiii i i  +* Re: We have a new standard!6Keith Thompson
4 Jan 25 iiii i i  i`* Re: We have a new standard!5Muttley
4 Jan 25 iiii i i  i `* Re: We have a new standard!4David Brown
4 Jan 25 iiii i i  i  `* Re: We have a new standard!3Muttley
4 Jan 25 iiii i i  i   `* Re: We have a new standard!2David Brown
4 Jan 25 iiii i i  i    `- Re: We have a new standard!1Muttley
4 Jan 25 iiii i i  `- Re: We have a new standard!1Ross Finlayson
2 Jan 25 iiii i `* Re: We have a new standard!30Sam
3 Jan 25 iiii i  `* Re: We have a new standard!29David Brown
3 Jan 25 iiii i   `* Re: We have a new standard!28Sam
3 Jan 25 iiii i    +* Re: We have a new standard!25Paavo Helde
3 Jan 25 iiii i    i+* Re: We have a new standard!23Sam
3 Jan 25 iiii i    ii+* Re: We have a new standard!5Muttley
3 Jan 25 iiii i    iii`* Re: We have a new standard!4Sam
3 Jan 25 iiii i    iii `* Re: We have a new standard!3Muttley
3 Jan 25 iiii i    iii  `* Re: We have a new standard!2Sam
4 Jan 25 iiii i    iii   `- Re: We have a new standard!1Muttley
3 Jan 25 iiii i    ii+* Re: We have a new standard!4David Brown
3 Jan 25 iiii i    iii`* Re: We have a new standard!3Sam
4 Jan 25 iiii i    iii `* Re: We have a new standard!2David Brown
4 Jan 25 iiii i    iii  `- Re: We have a new standard!1Sam
3 Jan 25 iiii i    ii`* Re: We have a new standard!13Paavo Helde
4 Jan 25 iiii i    ii `* Re: We have a new standard!12Sam
4 Jan 25 iiii i    ii  +- Re: We have a new standard!1Ross Finlayson
4 Jan 25 iiii i    ii  `* Re: We have a new standard!10Paavo Helde
4 Jan 25 iiii i    ii   +- Re: We have a new standard!1Sam
5 Jan 25 iiii i    ii   +- Re: We have a new standard!1wij
6 Jan 25 iiii i    ii   `* Re: We have a new standard!7Muttley
7 Jan 25 iiii i    ii    `* Re: We have a new standard!6Chris Ahlstrom
7 Jan 25 iiii i    ii     +* Re: We have a new standard!4Muttley
8 Jan 25 iiii i    ii     i`* Re: We have a new standard!3Chris Ahlstrom
8 Jan 25 iiii i    ii     i +- Re: We have a new standard!1Keith Thompson
9 Jan 25 iiii i    ii     i `- Re: We have a new standard!1Muttley
8 Jan 25 iiii i    ii     `- Re: We have a new standard!1Sam
4 Jan 25 iiii i    i`- Re: We have a new standard!1Ross Finlayson
3 Jan 25 iiii i    `* Re: We have a new standard!2David Brown
3 Jan 25 iiii i     `- Re: We have a new standard!1Sam
2 Jan 25 iiii `* Re: We have a new standard!3Michael S
2 Jan 25 iiii  `* Re: We have a new standard!2David Brown
2 Jan 25 iiii   `- Re: We have a new standard!1Michael S
2 Jan 25 iii`* Re: We have a new standard!2Keith Thompson
2 Jan 25 ii`* Re: We have a new standard!4Keith Thompson
1 Jan 25 i+* Re: We have a new standard!14Paavo Helde
2 Jan 25 i`- Re: We have a new standard!1Michael S
1 Jan 25 `* Re: We have a new standard!3Rosario19

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal