On Sunday, 4 November 2012 at 21:30:39 UTC, monarch_dodra wrote:
Not sure this is specific to D. Just because you pass something by value doesn't mean somebody else can't modify what's underneath.


By "D" I didn't mean the language, I meant the current practices in Phobos and other libraries, as compared to (say) the STL.


C++ gets away with this with an obsessive ownership model. Copy always trigger duplication of internals everytime anyting is ever passed by value. In D, you have dup, to do it only when you really need it.


Yeah, that's exactly what I mean. It's never ambiguous in C++ (although you certainly COULD make it ambiguous if you want to), because copying always, well, copies.


In D it's a mishmash of so many things you can't figure out when anything is copied or not...



Heck, D has it better than C++. If you want to use istream iterators in C++ (say, to interface with an algorithm), you can't chose char* as a re-useable output buffer. You HAVE to use std:::string, always allocating.


Better as in more potential for performance? Heck yeah.

Better as in, easier to reason about the code? Well, no, that's what's causing this whole thread...

Reply via email to