Also, accepting that "in" contracts should be "or"ed, interfaces still seem broken to me:

    import std.exception;

    interface Widthy {
        @property inout(int) width() inout;
        @property void width(int width) in { enforce(width < 0); }
    }

    class Test : Widthy {
    private:
        int _w;
    public:
        @property inout(int) width() inout { return _w; }
        @property void width(int width) in { enforce(width < 0); }
        body {
            _w = width;
        }
    }

    void main() {
        import std.stdio;
        auto t = new Test;
        t.width = -1;
        writeln("width: ", t.width);
        // width: -1

        // doesn't look right
    }

It does however behave how you describe if you use inheritance with 2 classes, or if you change the interface property's contract to:

   @property void width(int width) in { assert(0); }

Reply via email to