RFC: naming for FrontTransversal and Transversal ranges

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


On Thu, 30 Apr 2009 15:21:52 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> 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.
>
> The problem is what to do for the containers in Phobos.
>
> Andrei

Yes. I agree. Sorry, looking back, I interpreted what Rainer was talking  
about as applying to all structs and not as a supporting argument. It  
would have helped my understanding if the argument was concrete, i.e.  
about Rainer's actual experiences, and not a broad over-generalization.

Now, back on topic. I actually make heavy use of what amounts to structs  
containing arrays and don't want a deep copy >90% of the time. In fact, I  
haven't used any of the (my array-my array) deep copy functions and I only  
do copying when I have to convert my arrays to D style arrays or other  
container types. Also, D arrays are structs that contain C style arrays  
and I almost never dup them in final code. When I debug/prototype I do  
tend to use []= and dup more often. So I'd disagree that you'd almost  
always want to make a copy. Second, I don't think we should simplify the  
most common use case, but instead the majority of use cases. This is  
partly semantics, but partly not: everybody uses containers differently.

Also, Andrei, I would had preferred it if you had separated the discussion  
on arrays from Phobos containers. Many languages have arrays and a  
separate container library and I feel the decision of whether D's arrays  
should behave like Phobos' containers would be best left to after the best  
decision for Phobos is made.



More information about the Digitalmars-d mailing list