D dropped in favour of C# for PSP emulator

Kirill bribeme at gmail.com
Tue May 15 10:23:27 PDT 2012


On Monday, 14 May 2012 at 10:31:47 UTC, Simen Kjaeraas wrote:
> On Mon, 14 May 2012 12:01:06 +0200, Peter Alexander 
> <peter.alexander.au at gmail.com> wrote:
>
>> On Sunday, 13 May 2012 at 10:08:47 UTC, bearophile wrote:
>>> Andrei Alexandrescu:
>>>
>>>> assumeSorted(range).contains(object)
>>>>
>>>> is still one line, safer, and IMHO more self-explanatory.
>>>
>>> It's self-explanatory if the name there contains something 
>>> like
>>> "binarySearch". Otherwise it is NOT self-explanatory, I can't
>>> assume it will use a binary search.
>>> So it's surely not intuitive.
>>>
>>> Bye,
>>> bearophile
>>
>> 100% agree with this.
>>
>> How anyone can possibly think that using 
>> assumeSorted(r).contains(x) to do a binary search is more 
>> self-explanatory than just writing binarySearch(r, x) is 
>> beyond me. It's mind-boggling.
>
> It is not intuitive, I agree. It is, however, documenting. 
> You're not
> calling binarySearch on any old array, you assume it is sorted, 
> *then*
> search it.
>
> Perhaps it would be better to have a binarySearch function, 
> which can
> only take a SortedRange, and gives an explanatory error message 
> when used
> with a NonSortedRange.

How about users who don't know what binary search is. binary 
search is an intuitive concept for people who have good 
programming experience but assumeSorted(r).contains(x) is more 
intuitive to higher level users. see how many searches you get 
with binary search on google and how many with contains and 
sorted. I'm not a developer, I do quantum chemistry and write 
based on formulas and algorithms in papers, not on libraries. I 
would prefer people to write code in more general concepts so 
it's easier for me to understand and learn. And if you know 
binary search, it's not that much harder to change your style to 
assumeSorted(r).contains(x); in comparison, to a newbie learning 
binary search. Also having multiple ways of doing the same thing 
makes usage more confusing, so it should be avoided unless really 
needed.
So in short, I support that Andrei aims for larger audience.


More information about the Digitalmars-d mailing list