RFC: naming for FrontTransversal and Transversal ranges

Robert Jacques sandford at jhu.edu
Thu Apr 30 15:28:59 PDT 2009


On Thu, 30 Apr 2009 17:23:19 -0400, Rainer Deyke <rainerd at eldwood.com>  
wrote:
> Robert Jacques wrote:
>> On Thu, 30 Apr 2009 14:40:42 -0400, Rainer Deyke <rainerd at eldwood.com>
>> wrote:
>>> In addition, there's this: suppose you have a struct containing a
>>> (mutable) array.  When you make a copy of that struct, you will almost
>>> always want to make a copy of the contained array.  Therefore value
>>> semantics should be the default, because it simplifies the most common
>>> use case.
>>
>> That's what struct ctors/dtors/opAssign are for. Personally, I think
>> letting the struct designer decide the behaviour is better.
>
> I hope you're not suggesting writing ctor/dtor/opAssign for every single
> struct that uses arrays as value types.

I'm wasn't _suggesting_ anything. This is how D currently works, and is  
how any D library you're using that has structs that uses arrays as value  
types, works. Being surprised at my response gives me the feeling that  
you've never needed to code what you're talking about. If you have, your  
concrete example would be helpful as a use case in this discussion.

> It's possible to write a reference wrapper around a value type.  It's
> also possible to write a value wrapper around a reference type.
> However, the former is both easier and more efficient than the latter.

Yes and no. Yes, the deep copy mixin is more complex to write the first  
time, but after that it's easy to use. And second, it's just as efficient  
as the later, since the deep copy mixin generates the same code as a value  
type.




More information about the Digitalmars-d mailing list