DMD 0.167 release

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Mon Sep 18 12:56:01 PDT 2006


First of all, thank you Walter. Those look like some great features. And 
bugfixes are always good too :).


Juan Jose Comellas wrote:
> Thanks! Has the documentation on the digitalmars.com site been updated? I
> can't find the section for array literals.

Looks like it isn't updated on the site yet, but it's in the package: 
dmd/html/d/expression.html. The relevant quote:

     Array Literals

     Array literals are a comma-separated list of
     AssignExpressions between square brackets [ and ]. The
     AssignExpressions form the elements of a static array,
     the length of the array is the number of elements. The
     type of the first element is taken to be the type of all
     the elements, and all elements are implicitly converted
     to that type.

     [1,2,3];	// type is int[3], with elements 1, 2 and 3
     [1u,2,3];	// type is uint[3], with elements 1u, 2u, and 3u

One question about the above: When an array literal is used in the code, 
is the resulting array allocated on the stack?
I ask because it doesn't mention using dynamic memory allocation, nor 
does it mention the array being unusable after the scope ends...
(Since it allows AssignExpressions -- not just constants -- it can't 
generally be statically allocated, right?)



More information about the Digitalmars-d-announce mailing list