Feasible Idea?: Range Tester

monarch_dodra monarchdodra at gmail.com
Thu Mar 21 11:52:32 PDT 2013


On Thursday, 21 March 2013 at 17:29:46 UTC, Jonathan M Davis 
wrote:
> Hmmm. I've been working on stuff which makes creating ranges to 
> test range-
> based functions easier, but I've never thought about creating 
> something to
> test conformance.
>
> - Jonathan M Davis

One of the things I've been trying to deploy is a trait that 
would help identify *why* a range is (statically) non-compliant.

For example, when I was still not 100% up to speed on what it 
takes for a range to conform to this and that, I'd forget 
something, and it would take a lot of effort to realize that 
"dang, my save is not a property, that's why my range is not a 
random access range".

I wrote some traits called things like 
"assertIsRandomAccessRange!R". Contrary to 
"assert(isRandomAccessRange!R)", my function would output: 
"Assertion failed: R is not a random access range because it does 
not provide the save property".

This was quite a helpful tool but...

...It was mostly just code duplication. It would have been an 
helpful feature, but I'm not sure the code maintenance it 
entailed in std.range would have made it worth it.


More information about the Digitalmars-d mailing list