Trass3r <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #7 from Trass3r <> 2011-12-13 11:56:26 PST ---
(In reply to comment #6)
> Adding 'static interface' might be the way to differentiate between
> class-interface and struct-interface.
> In my case, struct is the right mechanism for speed and stack allocation, 
> while
> the interface is nice to provide a single point to document and to have the
> compiler verify.

Phobos circumvents the problem by using lots of templates in constraints:
template isInputRange(R)
    enum bool isInputRange = is(typeof(
        R r = void;       // can define a range object
        if (r.empty) {}   // can test for empty
        r.popFront();     // can invoke popFront()
        auto h = r.front; // can get the front of the range

While this works fine, it does have some disadvantages.
It adds lots of overhead cause all of that code must be evaluated with errors
gagged, mustn't alter the AST and whatever. Also there are a lot of bugs
introduced by that here in bugzilla.
Furthermore there are no useful error messages with template constraints, so
you don't even know what exactly went wrong when you implemented the interface.

> So for example, if an interface is declared "static interface" or "duck
> interface" or whatever, then getting a reference to it is impossible, because
> it makes no promises about the underlying type.

Yep, but one would need them as parameters. Maybe
foo(Bla b)
with Bla being a static interface could be shorthand for a compiler internal
equivalent of the currently used, ugly
foo(Blub)(Blub b) if (conformsToBlaStructure!Blub)

OTOH, how to express if you want a struct conforming to multiple structural

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

Reply via email to