The Thermopylae excerpt of TDPL available online

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 30 07:50:46 PDT 2009


Andrei Alexandrescu wrote:
> Saaa wrote:
>> Could anybody clear these up for me?
>>
>>> p16. Is there anything other than the random values, unsafe about 
>>> void assignment?
> 
> I'd put your feedback on my pile of things to do, but now that you ask, 
> I made this change to the incriminated paragraph:
> 
> ===========
> Such  uninitialized arrays  are particularly  useful for  large arrays
> that serve  as temporary buffers.   An uninitialized integral  may not
> cause  too   much  harm,  but  uninitialized  values   of  types  with
> indirections (such as arrays themselves) are unsafe.
> ===========
> 
>>> p18. What is unsafe about implicit conversion of static to dynamic 
>>> array?
>>>        Meaning getting a dynamic array pointing to a stack allocated 
>>> array.
>>>        Any operation changing its size could copy the array to the 
>>> heap. What am I missing
> 
> T[] fun() { T[10] a; return a; }
> ...
> auto x = fun(); // gained access to recycled stack memory
> 
> There's no change in size there.
> 
>>> p20. 10 int take up 40 words?
> 
> The example given has a per-row payload of 10 ints, i.e. 40 words.

It's bytes actually. So finally I rewrote those last words as:

"... small  per-row payload of~10  @int at s (40 bytes)."


Andrei


More information about the Digitalmars-d-announce mailing list