Lost a new commercial user this week :(

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 15 00:14:51 PST 2014


On 2014-12-14 22:00, Kiith-Sa wrote:

> One thing I ran into often when I was inexperienced with D:
>    the template constraints make some signatures extremely messy, and it
> takes a while to figure out when you have e.g. 3 template functions of
> the same name in
> std.algorithm, all with crypric signatures.
>
> Example:
>
> ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs
> needles) if (isForwardRange!R && Rs.length > 0 && isForwardRange!(Rs[0])
> == isInputRange!(Rs[0]) && is(typeof(startsWith!pred(haystack,
> needles[0]))) && (Rs.length == 1 || is(typeof(countUntil!pred(haystack,
> needles[1..$])))));
> ptrdiff_t countUntil(alias pred = "a == b", R, N)(R haystack, N needle)
> if (isInputRange!R && is(typeof(binaryFun!pred(haystack.front, needle))
> : bool));
>
> countUntil is trivial to use, but the docs make it seem complicated
> and it takes a while to read them.
> (This is not really a good example as with countUntil it's not *that*
>   bad, but I think it should be enough to show the problem)
>
> In this specific case, it would be useful if the constraint was somehow
> separated from the rest of the signature and less emphasized (CSS).

I completely agree. Using default arguments with values like __FILE__ 
and __LINE__ makes it look complicated as well, and though those 
parameters are most likely never used. The upcoming std.log is perfect 
example of this issue [1].

[1] 
http://burner.github.io/phobos/phobos-prerelease/std_logger_core.html#.logc

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list