Re: dxml 0.2.0 released

2018-02-15 Thread jmh530 via Digitalmars-d-announce
On Thursday, 15 February 2018 at 02:40:03 UTC, Jonathan M Davis 
wrote:


LOL. That's actually part of what makes writing range-based 
libraries so much harder to get right than simply using ranges 
in your program. [snip]


That sounds like an interesting topic for a blog post.


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Steven Schveighoffer via Digitalmars-d-announce

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


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Steven Schveighoffer via Digitalmars-d-announce

On 2/15/18 2:11 PM, Seb wrote:


I reworded the entire paragraph and it now shows the AST:

https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d/#4-whats-up-with-this-enforce 


eh...

"string which is an alias for an array of const(char) elements"

It's not actually, it's an array of immutable(char) elements.

But I think the reason we see const(char)[] delegate and not 
immutable(char)[] delegate, is that enforce's actual signature is:


T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg 
= null, string file = __FILE__, size_t line = __LINE__)


Not lazy string as you originally said.

https://dlang.org/phobos/std_exception.html#.enforce

In fact, you can see "string" output by the AST generator in other 
places (e.g. void main(string[] args) ), so even that whole explanation 
that it has "resolved" string already is misleading ;)


BTW, I have to click on the AST button on run.dlang.io (at least on my 
browser) to see the generated AST, it's not done automatically.


My idea was that we have this subtextual message: "look, D isn't 
complicated and we can always look behind the scenes".


I like the message, a lot! I think it's a very nice way to show some 
well-written D code while explaining each part so they make sense to 
outsiders.


-Steve


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Seb via Digitalmars-d-announce
On Thursday, 15 February 2018 at 16:22:17 UTC, Steven 
Schveighoffer wrote:

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!


Thanks!


Typos and Grammar:


Thanks a lot!
Yeah I shouldn't have published it directly after writing it...


This part is slightly incorrect:


Good point! Thanks.
I reworded the entire paragraph and it now shows the AST:

https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d/#4-whats-up-with-this-enforce

My idea was that we have this subtextual message: "look, D isn't 
complicated and we can always look behind the scenes".


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread aberba via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, 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.


Very well written. Nice read. I recommend you write more these 
days.