--- Comment #2 from 2012-04-06 10:09:17 PDT ---
(In reply to comment #1)
> My understanding is that you would usually put a static assert with
> isInputRange, or a more specific template from std.range immediately after the
> struct.

This is an example program:

import std.range, std.bigint;
struct Powers {
    int m;
    BigInt n;
    this(int m_) { this.m = m_; }
    const bool empty = false;
    BigInt front() { return n ^^ m; }
    void popFront() { n += 1; }
static assert(isInputRange!Powers);
void main() {}

If I compile it with DMD 2.059beta:

...>dmd -property -run temp.d
temp.d(10): Error: static assert  (isInputRange!(Powers)) is false

So it gives me no hint where the problem is. A built-in error message is
supposed to be more precise.

As alternative, maybe there is a way to add focused error messages inside a
isInputRangeVerify template to be used to verify that  an input range is
correct, that uses pragma(msg) or better ctWriteln.

> How is DMD supposed to know that that struct is suppose to be a range
> otherwise?

I see, it's a problem.
So here we are talking more about a probabilistic compiler tip. If the
class/struct contains a popFront and front and empty methods then the
programmer probably meants it to be a range.

Thank you for your answer.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to