More range woes: composed ranges are unsafe to return from functions

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 19 08:31:41 PDT 2012


On Fri, Oct 19, 2012 at 09:22:29AM +0300, Andrei Alexandrescu wrote:
> On 10/19/12 8:17 AM, H. S. Teoh wrote:
> >On Fri, Oct 19, 2012 at 04:24:53AM +0200, Marco Leise wrote:
> >>Am Tue, 16 Oct 2012 17:28:47 -0700
> >>schrieb "H. S. Teoh"<hsteoh at quickfur.ath.cx>:
[...]
> >>>Whew, what a day! Two compiler bugs, no less, and a whole bunch of
> >>>Phobos issues. I think I may need to take a break from D for a day
> >>>or two. :-/
> >[...]
> >>And that's where all the good projects end... :D
> >[...]
> >
> >Actually, I just went back to working on my personal D project for a
> >bit. I was a bit disappointed that what I thought would be a quick
> >side-job (implement cartesianProduct in std.algorithm) turned out to
> >get stymied by compiler bugs and Phobos issues.
> 
> Admittedly cartesianProduct is a nontrivial juxtaposition of quite a
> few other artifacts.

While it is by no means trivial, it is also relatively simple, as far as
functional programming goes. I'd say it's a "real-world" test of our
current implementation of map, zip, & co.. If we're going to be touting
functional programming in D, we'd better get our act together and make
sure putting these primitives together will always work correctly, lest
we get laughed at by real functional programmers.


> The question here is whether this is just endless churn or real
> progress. I'm optimistic, but am curious about others' opinion.

I'm not sure what you're referring to by "this". Are you talking about
cartesianProduct specifically, or something more general?


> [snip]
> >So yes, D still has a ways to go, and it does have its warts, but
> >it's heaven compared to C++.
> 
> One question is how it compares against other languages that foster
> similar bulk processing, such as C# or Scala.
[...]

I haven't programmed in C# and Scala, so I can't really say. I do have a
bias towards compiled languages, though, and so far D is the best of the
lot (that I've tried, anyway).


T

-- 
If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher


More information about the Digitalmars-d mailing list