Andrei Alexandrescu wrote:
Jason House wrote:
I'm a C++ refugee and value semantics make no sense to me. I always
declared classes (as part of function declaration) in C++ with a &...
Either T& or const T&. There were plenty of bugs where I messed up
and forgot the &. D is nice in that it tries to simplify that. You
yourself had issues with remembering ref parameters when implementing
ranges!
Good point, but the issue boils down to this: do we define container
members more often, or define container function parameters more often?
Because inside a data structure value semantics are useful more often
than not, and in a function parameter list reference semantics are
useful more often than not.
I do agree that D programmers grown used to cheap-to-pass data and I
don't want to cure anyone of hiccups :o).
Will it be an incurable mess if you let the programmer choose each time?
(Then we'd of course have this same discussion about which is the
default. :-) ) But still, I can see situations where it is _obvious_
which should be used.
Somebody into more functional style would have different needs than the
more imperative guy. Not to mention more specific situations.