Expressing range constraints in CNF form
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 12 12:28:07 PDT 2017
On Mon, Jun 12, 2017 at 10:35:59AM -0700, David Gileadi via Digitalmars-d wrote:
> On 6/11/17 1:32 PM, Sebastiaan Koppe wrote:
>
> > What about using ddoc?
> >
> > enum bool isInputRange(R) =
> > is(typeof((ref R r) => r)) /// must be copyable
> > && is(ReturnType!((R r) => r.empty) == bool) /// must support bool
> > empty
> > && is(typeof(lvalueOf!R.front)) /// must support front
> > && is(typeof(lvalueOf!R.popFront)) /// must support back
>
> If there's going to be compiler magic, this seems like a sensible
> syntax--documenting constraints is a good idea anyway, particularly
> for those of us who aren't is-expression masters.
+1, I like this idea much better than any of the others proposed so far.
No need for additional syntax, reuse ddoc comment syntax for something
that, ostensibly, could be considered documentation.
T
--
If lightning were to ever strike an orchestra, it'd always hit the conductor first.
More information about the Digitalmars-d
mailing list