Thursday, May 28, 2015

Quick Example

A reader might be curious about the syntax. This is a very short example program.



module my

type AType<S> {
    memref : Ref<S>;             ## default is private
 

    public self( s : Ref<S> ) {  ## constructor
        self.memref = s;
    }

    public getter()->Ref<S> {
   ## Ref<S> can also be written &S
         return self.memref;
    }
}

main()->Int {

    obj := new AType<Int>( 42 );
    ret := obj.getter();
    return ret;
}

No comments:

Post a Comment