If T[new] is the container for T[], then what is the container for T[U]?

Unknown W. Brackets unknown at simplemachines.org
Sat Apr 25 09:56:15 PDT 2009


Well, a range of an associative array is a possibility (not a slice, but 
e.g. from std.algorithm.)

I think it'd be a mistake to discount that.  Being able to treat 
associative arrays like arrays, in some cases (e.g. with count(), etc.) 
is nice.  That said, i don't even know that std.algorithm currently 
supports this.

-[Unknown]


Steve Schveighoffer wrote:
> On Sat, 25 Apr 2009 08:07:52 -0500, Andrei Alexandrescu wrote:
> 
>> It looks we can't make it with only T[]. We need a genuine container
>> type, and T[new] was suggested. It would probably have value semantics.
>>
>> T[U] seems to have the same problem. If T[U] is the range, then how do
>> you call the container?
>>
>> If we follow through with a no-garbage-collected option for the core
>> types, then we also need to distinguish between a slice and its
>> container. The fact that we (almost) got away with T[] being at the same
>> time the container and the slice was that the garbage collector would
>> collect all unused slices.
>>
>>
>> Andrei
> 
> You are confusing the difference between T[] and T[U].  T[U] is a strange 
> beast because it does not need to be new'd, but it acts completely like a 
> reference type.  But T[U] *is* the container type.  What you should be 
> asking is what is the *slice* type for T[U].  My answer would be that a 
> slice type for a hashtable doesn't make sense.  We don't need AAs to be 
> completely on par with normal arrays, so just leave them alone ;)
> 
> -Steve



More information about the Digitalmars-d mailing list