News for hackers. Stuff that matters.
Re:My Vision of D’s Future by abaga129 on Tuesday October 15, 2019 @02:22PM (#21261862)
Having to use .array() on the Result of some functions is the exact same problem I've ran into as well! D is by far my favorite language but there is definitely some room for improvement in terms of documentation on how to use the standard library.
Re:My Vision of D’s Future by anaphor on Tuesday October 15, 2019 @05:18PM (#21263918)
On the other hand, I like the explicitness of it instead of automatically converting to a different type. At least you know exactly what it's doing.

The python version of it would be calling `list()` on things all the time, which you might not always want to do.

Re:My Vision of D’s Future by abaga129 on Tuesday October 15, 2019 @06:46PM (#21264843)
That's a fair point. I'm not necessarily against having to do it, I just would like there to be a more obvious indication of how to convert the result to an array. It took a lot of searching the first time I came across this.

Perhaps it's just my own incompetence though!

Re:My Vision of D’s Future by anaphor on Tuesday October 15, 2019 @08:05PM (#21265542)
It's definitely not your incompetence. I started learning D a few months ago and it didn't click until someone on IRC explained it clearly to me. It's not in the tutorial or anything unless I missed it.
Re:My Vision of D’s Future by he_the_great on Thursday October 17, 2019 @12:04AM (#21278816)
It is the first thing I added to my articles when I introduced range based operations :

https://dev.to/jessekphillips/count-of-a-list-in-d-49k4

Re:My Vision of D’s Future by jordigh on Tuesday October 15, 2019 @02:52PM (#21262248)
It's not the best idea to always unconditionally use .array because you might want to preserve the laziness of a Result type. By using .array you're saying you want all of the results into memory right now! Depending on what you're doing, you might not want that.
Re:My Vision of D’s Future by abaga129 on Tuesday October 15, 2019 @06:48PM (#21264870)
I actually didn't know this! Very cool. I guess it's similar to calling .ToList() on IEnumerable<T> in C#.
Re:My Vision of D’s Future by p0nce on Wednesday October 16, 2019 @08:37AM (#21269676)
Most range function return a "Voldemort" that preserve lazyness if you put it in an `auto` local. Or you can use .array to get a slice out of it.