The answer to the problem can be found in the comments, but not in a single place: X {{}}; will: for T = DefCtor call the initializer_list constructor with a single default constructed element. The outer brakets are for the initalizer list and the inner ones are for the DefCtor constructor. The brackets for T constructor itself are allowed to be elided. for T = NoDefCtor, the previous overload resolution is not valid…
This issue is what stopped me contributing to the C++ standard. We knew brace initialisation was broken before C++11 came out, even std::vector was a mess.
Help me sort out the meaning of “{}” as a constructor argument
101–110 of 181 posts
Re: Help me sort out the meaning of “{}” as a constructor argument
#102Re: Help me sort out the meaning of “{}” as a constructor argument
#103Earlier quoted context omitted.
Haskell has syntax that is as problematic as this one, and a huge number of extension combinations that nobody can be sure not to be problematic. I'm running into it as much as I can too, but it does look like a language we should replace with something simpler once we get an specification that works.
> Haskell has syntax that is as problematic as this one... Examples, please.
(Patchy p, (~) ((* -> *) -> *) (ApplyState p) Tree) => Patchy (PatchInfoAnd rt p)Re: Help me sort out the meaning of “{}” as a constructor argument
#104Earlier quoted context omitted.
Obviously this is very hard to quantify but for me the cognitive overload of being a good C++ is massively higher than for languages like Java, Python or JavaScript. C++ to me clearly has significantly more undefined behaviour, compiler specific behaviour and other quirks along with less safety nets (e.g. garbage collection, null pointer checks). Do you really find JavaScript, Ruby, Java and Ruby harder to master tha…
The blog post was about a possible bug in the syntax/standard itself. I pointed out that all languages have weird edge cases and buggy syntax. If you want to discuss programming languages in general then that is a totally separate discussion. C++ is not in the same class of languages as JS or Ruby, so why would you use them interchangeably? C++ is meant for low level system programming, when performance or size are c…
> Also, JS and Ruby are indeed just as hard to master as C++.
I have to call Bull on this part, with apologies for the tone (but I don't know any better way to put it). How on earth you can claim JS is harder than C++? C++ is doubtlessly a much more complicated language than JS, and for good reasons (albeit a good portion of those are historical). However sub-optimal JS is (for it was designed with hardly any gestation time and on a ridiculously tight schedule), it can be taught, almost completely in a matter of hours (sans the DOM). Add a couple more hours for teaching browser security models and pointers on where to find docs for everything JS.
Re: Help me sort out the meaning of “{}” as a constructor argument
#105I've been programming professionally for over 20 years, most of it in C++. I really like developing fast code, and C++ used to be my favorite tool for the job. But the language complexity gets more insane with every revision. It's now at the point where Scott Freakin' Meyers can't figure out the interpretation of a short little chunk of code. I'm now actively looking for gigs in which I can develop high-performance c…
Re: Help me sort out the meaning of “{}” as a constructor argument
#106Earlier quoted context omitted.
Undefined behavior is not specified, by definition! It is the absence of requirements, including the requirements to diagnose. C++ has something called "unspecified behavior" also, which is stronger than undefined, because it gives requirements. It denotes some circumstances when an implementation can behave in one of a finite possible ways (none of which fail) and must choose one of them without documenting which ch…
> Undefined behavior is not specified > unspecified is stronger than undefined because it gives requirements. I do not understand what you are saying.
"undefined behavior" refers to situations in which no requirements apply at all. (Truly unspecified in the regular sense of the word.)
Re: Help me sort out the meaning of “{}” as a constructor argument
#107Earlier quoted context omitted.
> Haskell has syntax that is as problematic as this one... Examples, please.
I've just looked at this line in darcs documentation: (Patchy p, (~) ((* -> *) -> *) (ApplyState p) Tree) => Patchy (PatchInfoAnd rt p)
Re: Help me sort out the meaning of “{}” as a constructor argument
#108Earlier quoted context omitted.
C was already bad when it was born, comparing with what Burroughs was doing in Burroughs B5000 in 1961, nowadays sold by Unisys ClearPath MCP. Or other similar languages on those days, like Concurrent Pascal on Solo OS (1975). When I learned C in 1993, it seemed quite poor compared to my Turbo Pascal 6.0 type safety and respective language features.
The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.) and had some very handy shortcuts for often used operations like ()?:, ++, --, += etc. Less verbose language, less need to type syntactic structures. You could basically keep the flow of what is in your mind with the progress on your keyboard and forget about typing it; you were simply ass…
Speaking as a developer who works mostly in C and C++, that's a pretty crappy advantage. Based on the answers here[1], it seems like the real benefits were a more permissive type system, better library, separate compilation units, and better ways to directly access hardware.
Re: Help me sort out the meaning of “{}” as a constructor argument
#109Earlier quoted context omitted.
Exactly, the "custom syntax" is the problem. The problem is that Scala seems to attract the same type of thinking as C++, where there is a culture that rewards obscure, bizarre syntax. I mean, why is it an exclamation mark to send messages to actors in Akka? I need to write code to get things done. I want to spend minimal time figuring out bizarre operator-overloaded library syntax.
"I need to write code to get things done. " Yes. But their cultures are a little different. C++ I think is 1/2 academic, 1/2 Engineering - with a lot of voices, and a lot of anachronistic 'grey beards' arguing over stuff. Even for Java, James Gosling said 'Sun less less a company than it is a debating society'. Scala is almost purely academic - but driven by a single person / small team. Scala was not designed to sol…
Re: Help me sort out the meaning of “{}” as a constructor argument
#110Earlier quoted context omitted.
None of the companies of my dreams was using C and "ACM ICPC and similar competitions" was done in Prolog.
Is this a typo for Pascal? When I did the ICPC, Prolog was not a permitted language in my region, and IIRC not at worlds either. But Pascal was (which I always found quaint, but perhaps that was my provincialism).
But we had "... similar competitions", one of them was national logic programming competitions.