The Thermopylae excerpt of TDPL available online

Leandro Lucarella llucax at gmail.com
Thu Oct 29 09:31:09 PDT 2009


Leandro Lucarella, el 29 de octubre a las 13:21 me escribiste:
> Andrei Alexandrescu, el 28 de octubre a las 23:38 me escribiste:
> > It's a rough rough draft, but one for the full chapter on arrays,
> > associative arrays, and strings.
> > 
> > http://erdani.com/d/thermopylae.pdf
> > 
> > Any feedback is welcome. Thanks!
> 
> It looks very nice. A small error in 4.1.7 first code block:
> 
> auto a = new double[4];          // must be already allocated
> auto a1 = [ 0.5, -0.5, 1.5, 2 ];
> auto a2 = [ 3.5, 5.5, 4.5, -1 ];
> a[] = (a1[] + a2[]) / 2;         // take the average of b and c
>                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                                    take the average of a1 and a2?
> 
> (I think it would be easier to follow using b and c though ;)

BTW, it looks like array literals will be dynamic arrays, from the code in
your book. Can you or Walter explain why this is better to make array
literals statically stored immutable memory like strings (which adds an
inconsistency to the language)? Is this just to avoid [1,2,3].dup; when
you want to get a dynamic array from an array literal or is there other
reasons?

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
En la calle me crucé con un señor muy correcto, que habitualmente anda en
Falcon; iba corriendo con dos valijas en la mano y dijo: "Voy para Miami,
tiene algún mensaje o ..." y le dije: "No, no, no..."
	-- Extra Tato (1983, Triunfo de Alfonsín)



More information about the Digitalmars-d mailing list