Why is std.algorithm so complicated to use?

Timon Gehr timon.gehr at gmx.ch
Mon Jul 16 13:53:36 PDT 2012


On 07/16/2012 05:22 PM, Don Clugston wrote:
> On 10/07/12 16:59, Andrei Alexandrescu wrote:
>> On 7/10/12 9:59 AM, H. S. Teoh wrote:
>>> On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
>>>> On 7/10/12 2:50 AM, Jacob Carlborg wrote:
>>>>> On 2012-07-09 22:16, Andrei Alexandrescu wrote:
>>>>>
>>>>>> So foo is a range of strings, because each element of it is a
>>>>>> string. Then you want to chain a range of strings with a string,
>>>>>> which is a range of dchar. That doesn't work, and I agree the error
>>>>>> message should be more informative.
>>>>>
>>>>> Is that by design or something that can be fixed?
>>>>
>>>> We can arrange things in the library that a custom message is issued,
>>>> or in the compiler to do it once for all.
>>>
>>> Please don't do it in the compiler. Custom messages should be in the
>>> library. Tying the compiler to phobos is a bad idea; druntime should be
>>> the only dependency.
>>
>> The idea there being that the compiler could give good details about
>> what part of a complex constraint has failed.
>
> However the compiler doesn't know which constraint was supposed to pass.
> If it is lucky enough to only have one template, it can do it, but if it
> has:
> template1 if (A && B)
> template2 if (C && D)
> template3 if ( (E || F) && G)
>
> should it print:
> foo.d(99): Error: no matching template
> foo.d(10): constraint failed: A
> foo.d(28): constraint failed: D
> foo.d(57): constraint failed: (E || F)
> ?
> Could be a very long list, if there are many templates.
>
> Determining the minimal list of constraints seems like a nice
> application for BDDs...
>

Well, are template constraints likely to contain a lot of redundant 
information?


More information about the Digitalmars-d mailing list