←back to thread

178 points todsacerdoti | 2 comments | | HN request time: 0.434s | source
Show context
user-the-name ◴[] No.26340320[source]
"emplace_back"? People actually looked at this and went "Yes, this is a good function name. I understand this perfectly."?
replies(5): >>26340335 #>>26340345 #>>26340374 #>>26340547 #>>26343435 #
dmurray ◴[] No.26340374[source]
All the simple names and most of the syntax were taken in C++98. This is one of the problems with backwards compatibility: even if everyone migrates to the new standard on its first day, so you never actually have to target the old compiler, the simplest way to do things will often be the old way.

Also, in mitigation, it's not a special-purpose word for appending to vectors. They introduced "emplace" to other STL data structures at the same time, with the equivalent semantics, so it's a word you only have to learn once.

replies(1): >>26340944 #
user-the-name ◴[] No.26340944[source]
I mean, this is entirely a self-inflicted problem. If you'd just use a few more words in the name, none of this would be an issue.

There's nothing wrong with longer function names. They make code a lot easier to read.

replies(2): >>26341110 #>>26341149 #
dmurray ◴[] No.26341110[source]
You'd prefer something like vec.construct_then_push_back(foo, bar)? I think it's reasonable that people would want a pithier name than that, for something you're going to use constantly.
replies(2): >>26341122 #>>26341251 #
1. bregma ◴[] No.26341251[source]
I think they mean `std::vector::construct_back_in_place()`. 200 character line widths will no longer be enough: 400 or 500 will be more realistic. Sacrifice readability for readability.
replies(1): >>26349548 #
2. user-the-name ◴[] No.26349548[source]
How many function calls do you put on a single line? Break those statements up!