My experience making an on-disk merge sort using ranges

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Feb 26 21:21:37 PST 2013


On Tue, Feb 26, 2013 at 11:21:41PM -0500, Andrei Alexandrescu wrote:
> On 2/26/13 10:31 PM, Chris Cain wrote:
> >After reading bearophile's post, I realized I neglected to mention I
> >was using 2.062.
> >
> >On Wednesday, 27 February 2013 at 03:16:39 UTC, bearophile wrote:
> >>
> >>With the latest compiler this compiles to me
> >>...
> >
> >Interesting. map!text() compiles but it crashes. It's worth noting
> >that map!text().cached() works without crashing on my end.
> >
> >That said, it's not the first time I've seen Object Violation while
> >working on this problem. Although, I was previously certain the times
> >it was failing with that was my fault (because I was trying to
> >implement a version of a wrapper where I mistakenly took the address
> >of the value type MapResult without thinking that it meant I was
> >taking the address of the stack ... whoops).
[...]
> 
> In all likelihood these are manifestations of simple bugs. Please
> submit all cases that should work but are failing (in the same bug
> report) and we'll get them fixed.
> 
> Thanks for your work! nWayUnion is a pretty darn slick algorithm.
[...]

Random marginally-related remark: levenshteinDistanceAndPath is an even
cooler inclusion in Phobos. The name is kinda off-putting, though, since
it didn't immediately occur to me what Levenshtein distance at a glance,
but this is essentially the Unix diff utility built right into Phobos.

Let me put that another way...

<anecdote>
I was writing a utility for verifying the coordinates of some geometric
data I'm working on, and my first stab at it was a little D program that
could tell whether there was an error, but couldn't pinpoint where it
might be. I had large arrays of coordinates, so I wondered how to show
the errors. I could display the first few mismatches, but what if an
entry or two were merely missing? Then there'd be lots of irrelevant
output from the remaining shifted items that would have matched
otherwise. Then I vaguely remember something that might be helpful in
std.algorithm and looked over it again more carefully, and lo and
behold, sitting right there was levenshteinDistanceAndPath. It allowed
me to instantly pop it in and display a minimal diff of the incorrect
data vs. what the expected data should be. Instant Phobos win!!
</anecdote>

<rave>
If only the naysayers knew how cool Phobos will be once we clean it up
and polish it into the high-quality product that it should be. It's
already showing its coolness right now by being able to do diffs in a
completely generic way -- not of mere text lines like the Unix diff can
only do, but of *arbitrary D data*!!  Need to do some custom diffing?
It's already in Phobos in completely generic form, just waiting for you
to instantiate it with your particular data types!
</rave>


T

-- 
Windows: the ultimate triumph of marketing over technology. -- Adrian von Bidder


More information about the Digitalmars-d mailing list