D dropped in favour of C# for PSP emulator
Anders Sjögren" <anders at sjogren.info>
Anders Sjögren" <anders at sjogren.info>
Wed May 16 00:05:28 PDT 2012
Since this post is about inuition, I'll raise my voice even
though I'm a total D newbie (with background in C++, C#, Haskell,
etc.).
From my point of view, the AssumeSorted way makes sense, but
without getting a hit on it when searching for BinarySearch it's
a bit cryptic. On the other hand, with search hits on the subject
in the documenation, anyone should be able to use it. It's a
matter of choosing if you want to express what should be done or
how it should be done.
The concern I can see is about the difference in contract.
BinarySearch explains how the operation is being performed and
_promises_ to do a binary search. Contain does not promise how
it's performed (that's the whole point, right?) and you're at the
mercy of the library writer. For carefully profiled code, that
can be a disadvantage, since any implementation change could lead
to hidden changes in performance characteristics. Then you might
want the control over exactly how the operation is performed.
The way I see it, both AssumeSorted.Contains and BinarySearch are
overlapping in functionality (i.e. a fast search) but not
equivalent in contract.
More information about the Digitalmars-d
mailing list