Feasible Idea?: Range Tester
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Mar 21 11:55:48 PDT 2013
On Thu, Mar 21, 2013 at 07:52:32PM +0100, monarch_dodra wrote:
> 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.
I think this is worth doing if you already wrote the templates to do
these checks.
Ranges are an extremely powerful concept in D, but they are also very
obscure for a beginner, and the current error messages don't help.
Improving the assertions' messages would be a big improvement, IMO.
T
--
People tell me I'm stubborn, but I refuse to accept it!
More information about the Digitalmars-d
mailing list