The Expressive C++17 Coding Challenge in D

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 15 16:22:17 UTC 2018


On 2/13/18 6:35 PM, Seb wrote:
> Someone revived the Expressive C++17 Coding Challenge thread today and I 
> thought this is an excellent opportunity to revive my blog and finally 
> write an article showing why I like D so much:
> 
> https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d
> 
> It's mostly targeted at beginners as I explain many basic D features, 
> but maybe it's helpful for beginners looking into D.

Nice article!

Typos and Grammar:

" How often how you encountered code like a + b"

How often have

---

"Yes, the D compiler does all the hard work for."

for you

---

"In short: the compiler does a few smart lowering for you"

lowerings

---

"Yes D is statically typed, but the compiler is pretty smart, so we can 
let him do all the hard for for us."

hard work

"auto is a filler word for the compiler that means “whatever the type of 
the assignment, use this as type of this variable”."

the type

---

"Okay to recap, we have taken the input of a file by line, splitted 
every line by commas"

splitting

---

This part is slightly incorrect:

" Isn’t this done before the enforce is called?

No, lazy is lazy and the string concatenation doesn’t happen at the 
caller site, but can be requested explicitly by the callee."

Technically, the concatenation is done at compile-time, which can be 
seen via AST: https://run.dlang.io/is/OVKxee

But normally, if the concatenation involved runtime strings, it would be 
done lazily.

-Steve


More information about the Digitalmars-d-announce mailing list