On Sat, 08 Jun 2013 05:52:49 +0100, Eric <e...@makechip.com> wrote:

On Saturday, 8 June 2013 at 02:32:57 UTC, bearophile wrote:
Eric:

Yes, the template constraint is much better. However, the compiler still crashes, even with the new code:

Because there's a type definition loop, regardless. Using a constraint doesn't change that situation.

Bye,
bearophile

How is there a type definition loop?  I'm just trying to constrain
the interface.  At a minimum this should be a compiler bug, but
I would hope that dimple constraints would work.

There is a type loop but I agree the compiler should really be able to catch it.

Using bearophile's short example..

import std.traits: hasMember;
interface Xidentity(V, K) if (!hasMember!(V, "x")) {
}
class Foo(K): Xidentity!(Foo!K, K) {
    K x;
}
void main() {
    new Foo!double;
}

The compiler starts by generating the template for Foo(double), requiring Xidentity(Foo!double,.. requiring Foo(double), requiring Xidentity(Foo!double,.., and so on..

It should really be able to detect that it is re-generating the original Foo(double) and simply re-use/terminate the loop there, I think. (I am no compiler expert however)

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to