Developing a plan for D2.0: Getting everything on the table
Rainer Deyke
rainerd at eldwood.com
Mon Jul 27 11:37:55 PDT 2009
Leandro Lucarella wrote:
> About values vs. reference semantics, I think reference is the best.
> Containers usually are big, and you don't want to copy them arround.
> I find myself using lots of references to pass containers arround in C++
> and almost never use the copy() method of Python containers, so based on
> *my* experience, I'd say that reference as the default is the best
> approach.
I don't think the choice of reference vs value semantics has *anything*
to do with how often something is copied. To me, the relevant questions
are:
- Do you have strict ownership relationships? (Usually you do.)
- Do you want to avoid long-distance bugs? (Yes you do, always.)
Orthogonal question: does copying *ever* make sense:
- If yes, provide a copy operation.
- If no, prevent copying.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list