dcollections 1.0 and 2.0a beta released

Ellery Newcomer ellery-newcomer at utulsa.edu
Fri May 21 09:55:58 PDT 2010


On 05/21/2010 09:14 AM, Steven Schveighoffer wrote:
> Second, since reference types are the right thing to do, classes are much easier to deal with.  I know AA's are reference types that are structs, but the code needed to perform this feat is not trivial.  The AA has only one member, a reference to the data struct, which is allocated on the heap.  Any member function/property that is used on the AA must first check whether the implementation is allocated yet.  The only benefit this gives you IMO is not having to use 'new' on it.  And even that has some drawbacks.  For example, pass an empty AA by value to a function, and if that function adds any data to it, it is lost.  But pass an AA by value with one element in it, and the new data sticks.  A class gives you much more in terms of options -- interfaces, builtin synchronization, runtime comparison, etc.  And it forces full reference semantics by default.  I think regardless of whether interfaces are defined for dcollections, classes give a better set of options than structs.


Wow. A partially-nullable type.

Great. Now I have to review everywhere I ever used an AA. Thanks, D.

is there any serious drawback to something like

(int[int]).init = InitializedAA!(int,int)

?


More information about the Digitalmars-d-announce mailing list