T[new]

Stewart Gordon smjg_1998 at yahoo.com
Mon Aug 10 11:36:17 PDT 2009


Jeremie Pelletier wrote:
<snip>
> Walter: what will the string types be aliased to now: still immutable(char)[] or immutable(char)[new]?
> 
> I think it would be best to have them use the array [new] type.

It would be more efficient to cut out this middleman for things that 
aren't going to change the length.  Which means most things that operate 
on the string type (and similarly wstring/dstring), since these types 
are designed to be immutable.  The change to T[] that's part of this 
plan would take it a stage further by making the length immutable as well.

> Functions which do not modify the string length can mark the string
> as an in parameter, and immutable(char)[] should be castable to
> const(immutable(char)[new]) in such cases to still allow slices to be
> passed.

The conversion would create an extra memory allocation.

Stewart.



More information about the Digitalmars-d mailing list