Hacker News new | ask | show | jobs
by gurkendoktor 3276 days ago
I wish Swift focused on reference semantics. One of the big problems of value types in C++ is that you have to be a language lawyer to not accidentally make wasteful copies of everything, and the same is true of Swift:

http://rosslebeau.com/2016/swift-copy-write-psa-mutating-dic...

I thought Objective-C had already solved this problem quite nicely with the explicit NSFoo/NSMutableFoo class pairs. I don't see why this needed to be fixed again, in a less explicit way.

3 comments

> One of the big problems of value types in C++ is that you have to be a language lawyer to not accidentally make wasteful copies of everything...

Not always. The C++ standard has allowed copy elision for some time [1]. Guaranteed copy elision for certain forms of copy has been proposed for C++17 [2].

[1] http://en.cppreference.com/w/cpp/language/copy_elision

[2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p013...

The conflation of values (which exist in the language's semantics on paper) with physical representations (which exist in computer memory) plagues most imperative languages that try to do value semantics.