Andrei Alexandrescu wrote:
> http://www.reddit.com/r/programming/comments/975ng/diving_into_the_d_programming_language_tdpl/
> 
> 
> (Don't tell anyone, but I plan to rewrite it.)
> 
> Andrei

Dump of thoughts as I read it:

-- Personally, I've replaced "Hello, World!" in my own code with "Don't
Worry, Be Happy!".  Making the program whistle through the PC speaker
optional.

(Actually, I made that last bit up, but now I have an overwhelming urge
to work out how to do it...)

-- What's with all the quote marks in the heights example?  I... OOOH...
feet and inches.  Out of interest, is it correct to replace "''" with
"\""?  Also, maybe put " cm" on the end of the line.

-- Why immutable and not enum?  They're not only unlikely to change,
they don't need to be stored in the program.

-- Re: writefln example.  I thought integers were %d, not %i.

-- "Assigning to arr.length reallocates the array."  Shouldn't that be
something along the lines of "Assigning to arr.length reallocates the
array if you try to make it larger."?

-- "by setting to write a binarySearch" -- "by setting" doesn't really
parse.

-- "in D, the semantics of a module-level symbol never depends on its
relative ordering with others."  HAHAHAHAHAHAHA!  Oh, that's a good one.
 Glad to see you have a sense of humour.  :D

-- What is freqs.keys if not an array? (You call array on it, indication
that it puts it in "array format", but don't explain what would happen
if you don't do that.)

-- startsWith and tolower have inconsistent capitalisation.  Just
sayin', is all.  :)

-- Following the style guide, shouldn't "postprocess" be "postProcess".
 Everyone's free to use whatever style they like, but since this is the
"official" book, I just wonder if it should follow the guide.

-- I realise it's a simple example, but wouldn't double.inf or, better
yet, double.nan, be a more appropriate initialiser?  double.inf is the
absolute largest value you could possibly get (imagine the input
contains an exceedingly large value that overflows to inf; the output is
no longer accurate.)

double.nan is even better because unless the input is malformed, you
can't get it.  Of course, then you need to be a little trickier in how
you write your test; if (!(x >= min)) { min = x; } should do it.  Then
again, this requires you to explain wtf is going on... :P

-- You don't indicate what enforce does.

Closing thoughts:

I like it.  It's easy to read and well-written.

Reply via email to