Home /Modules/impl/static-protected.sleela

static-protected.sleela

impl/examples/static-protected.sleela · 29 line(s) · sleela

#sleela 2.1
// System viewpoint model:
// next       = Degree 1
// next.next  = Degree 2 proposal
// A static Degree-2 extension gains another two viewpoint degrees:
// next.next.next.next = Viewpoint Degree 4.
//
// A Degree-2 viewpoint may observe both Degree 1 and Degree 2 values.
// The compiler back-propagates the request for Degree 1 to the origin so
// that visibility remains a programmatic, bounded operation.

class ProtectedSystem {
    static protected int systemDegree = next.next;
    static protected int viewpointDegree = next.next.next.next;
    static protected int protectedState = 7;

    static protected int readState() {
        return protectedState;
    }

    void main() {
        print("next = " + next);
        print("next.next = " + next.next);
        print("static Degree-2 viewpoint = " + viewpointDegree);
        print("system degree = " + systemDegree);
        print("protected state = " + readState());
    }
}