Live data from Hacker News

Help me sort out the meaning of “{}” as a constructor argument

scottmeyers.blogspot.com

101–110 of 181 posts

Re: Help me sort out the meaning of “{}” as a constructor argument

#101

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.

Well, the issue is not brace initialization per se, but the ambiguity with initilalizer_list.

Re: Help me sort out the meaning of “{}” as a constructor argument

#103

Earlier 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.

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

#104
post #47

Earlier 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…

I agree with most of your post. The domain of C++ and JS are widely apart. Comparing C++ and JS is hardly justified, IMHO. However if we were to compare them:

> 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

#105

I'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…

Amen. I was just thinking the other day about how I used to really like C++ but how glad I was to not have to use it anymore. I haven't worried about "the most vexing parse" for years! There was this last week, and yes it's contrived but it suggests something has gone horribly wrong: http://stackoverflow.com/questions/40462612/moving-a-member-... .

Re: Help me sort out the meaning of “{}” as a constructor argument

#106

Earlier 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.

"unspecified behavior" in C++ is a formal term denoting a situation in which requirements are in fact given. There are multiple possible requirements, and the implementation chooses which apply, without having to document the choice. So in fact something is specified, just not entirely.

"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

#107

Earlier 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)

The C++ usage (T x{{}}) is problematic because its interpretation is so obscure as to flirt with ambiguity and lead to program-breaking changes in compilers as their semantic analyzers improved. The Haskell line you cite isn't ambiguous at all.

Re: Help me sort out the meaning of “{}” as a constructor argument

#108
post #44
post #36

Earlier 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…

> The main advantage of C was that it allowed you to type stuff super fast comparing with Pascal ( {} instead of Begin .. End etc.)

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.

https://www.quora.com/Why-did-C-succeed-over-Pascal

Re: Help me sort out the meaning of “{}” as a constructor argument

#109

Earlier 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…

Scala is increasingly used in projects that underpin allot of todays infrastructure, for example Kafka, Spark, Akka and Finagle.

Re: Help me sort out the meaning of “{}” as a constructor argument

#110
post #96
post #57

Earlier 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).

No, we didn't had anything like ICPC in the 90's on my home country, at least it wasn't known to us.

But we had "... similar competitions", one of them was national logic programming competitions.

Post reply on HN