Top 5

Sergey Gromov snake.scaly at gmail.com
Fri Oct 10 07:25:34 PDT 2008


Fri, 10 Oct 2008 08:22:10 -0500,
Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
> > My T[] is useful when you want to recursively split a megabyte file into 
> > a couple thousands of tokens, and then modify some of those tokens.  For 
> > that, your T[] must be lightweight, it must reference a bigger piece of 
> > data, and it must guarantee not to write anything into memory outside 
> > its boundaries.
> > 
> > The Array is for appending.  It must always own its memory.  Therefore 
> > you should be able to pass it around by reference, so Array is a *class* 
> > and cannot be nearly as lightweight as T[].
> > 
> > You see, many of their properties are orthogonal.  If you drop one, you 
> > lose flexibility.
> > 
> >> Besides, Array!(T) is not a good name for build-in type.
> > 
> > Names are placeholders here, not an actual proposal.
> 
> What's wrong with making Array a library type?

Well, I'd like
  new Object[15];
to be immediately appendable and therefore a syntactic sugar for 
  new Array!(Object)(15);
I'd also like
  "foo" ~ text ~ "bar"
to become something like
  (new Array!(char)) ~= "foo" ~= text ~= "bar"
that is what Java does to string concatenation.  Sugar doesn't seem to 
couple well with a purely library type.

Well, the latter is probably too complex and can cause major problems.  
But new T[] should return something appendable.



More information about the Digitalmars-d mailing list