Debug help - Ranges - Programming in D page 598

monkyyy crazymonkyyy at gmail.com
Thu Aug 28 15:48:10 UTC 2025


On Thursday, 28 August 2025 at 15:21:41 UTC, Andy Valencia wrote:
> On Thursday, 28 August 2025 at 14:15:54 UTC, monkyyy wrote:
>
>> They lose the plot and you have to sometimes offer your own 
>> solutions, its often not worth debugging, if you see an ugly 
>> phoboes error on what should be a simple range concept, 
>> consider not even looking.
>
> Although at least consider submitting a suggestion on a better 
> error message.

Its **wrong** that op's code fails. That op has a reasonable 
range and cycle isnt that hard for a naive implementation. (tho 
someone will likely rant at me about .save)

If I can write 10 lines replacement code where a 1000 lines of 
code doesn't work, something with your 1000 lines of code is 
wrong.

> It's clear the ldc2 compiler has evolved towards being much 
> more helpful; perhaps the Phobos team will file off some rough 
> edges based on user experience.
>
> Andy

My suggestion for better template hell error messages is here; 
walter did not get it:

https://forum.dlang.org/thread/fwxpamdmlrmoqtkazupn@forum.dlang.org

and look at that, cycle implements template landmines: 
https://github.com/dlang/phobos/blob/205256abb1f86faf986f8c789cb733ca4137246e/std/range/package.d#L4687

*Such things are trade offs*, maybe you correctly inferred all 
types correctly(but clearly not in practice, see above) but if 
you ever pattern match into a static assert; *less code works*. 
Hot take: writing code that makes less code work is a bad use of 
code writing time.

> perhaps the Phobos team will file off some rough edges based on 
> user experience.

Phoboes is far past the point where further complexity tradeoffs 
make sense even by their estimation.


More information about the Digitalmars-d-learn mailing list