new T[10] => new T[](10)

BCS none at anon.com
Sun Feb 14 15:35:28 PST 2010


Hello Andrei,

> Now with the full legitimization of statically-sized array, the
> syntactic kludge "new T[10]" is more painful than ever.
> 
> Walter and I were talking about changing the semantics of "new T[10]"
> to mean "allocate a T[10] object and give me a pointer to it" and make
> the syntax "new T[](10)" mean "allocate an array of 10 elements and
> give me a handle to it."
> 
> I see major disruptions of existing code though. Do you guys have
> ideas of a clean migration path?
> 

I'm not seeing a problem.

given: new T[exp]

If exp is not a compile time constant, return a dynamic-sized array of the 
runtime evaluated value.
else return a statically-sized array that can be implicitly converted to 
a dynamic-sized array.

The only problem I see is: how would this interact with CTFE?

--
<IXOYE><





More information about the Digitalmars-d mailing list