What are (were) the most difficult parts of D?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu May 12 18:07:05 UTC 2022


On Thu, May 12, 2022 at 09:04:09AM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 5/11/22 18:06, Christopher Katko wrote:
> 
> > Cool useful library functions like sumElement that magically don't
> > work on static arrays.
> 
> Yeah, that sometimes gets me as well. Although it is trivial to deal
> with, the programmer may be surprised by the strange error messages:
> 
>   int[3] arr = [ 1, 2, 3 ];
>   assert(sum(arr) == 6);
> 
> Error: template `std.algorithm.iteration.sum` cannot deduce function from
> argument types `!()(int[3])`
> /usr/include/dlang/dmd/std/algorithm/iteration.d(7234): Candidates are:
> `sum(R)(R r)`
>   with `R = int[3]`
>   must satisfy the following constraint:
> `       isInputRange!R`
> 
> WHAT? :) But the clue is on the last line above.
[...]

Seriously though, that error message is horrendously ugly.  I mean I've
seen it thousands of times by now, so I know what it means and where to
look for the actual problem. But it's eminently unfriendly to someone
who doesn't already know the language very well.


T

-- 
A mathematician learns more and more about less and less, until he knows everything about nothing; whereas a philospher learns less and less about more and more, until he knows nothing about everything.


More information about the Digitalmars-d-learn mailing list