class ##ERROR: syntax error - no class body --- class B ##ERROR: syntax error - no class body --- class B ( ##ERROR: syntax error - block expression expected as 'class' body ) --- class B + ##ERROR: syntax error - prohibited binary selector '+' --- J := 11 class B { if (== J 10) { fun :*newA() { return self } } else { fun :*newB() { return self } } } t2 := (B:newB) t1 := (B:newA) ##ERROR: exception not handled - "unable to send newA to B - 'newA' not found in B" --- class B [ x ] { if (x > 0) { ##ERROR: syntax error - prohibited access to instance variable - x } } --- class B [ x y ] { }; class X :: B [ a b ] { fun :* new(t) { | a | set self.a t; set a 100; set self.b (* t 2); set self.c (fun(b) { ##ERROR: syntax error - unknown class-level variable name printf "xxxx [%d]\n" b; }); return self; }; fun print() { self.c (+ self.a self.b); printf "a=%d b=%d\n" self.a self.b; } }; --- class X { fun :* xxx() { return X; } fun :* qqq() { return "hello" } fun String:length() { ##ERROR: syntax error - function name not valid return (str.length self) } } --- class X { fun :* xxx() { return X; } fun :* qqq() { return "hello" } } ## this triggers a runtime error as J isn't a class name fun J:ccc() { ##ERROR: exception not handled - "J accessed without initialization" return 999 } --- X := 20 ## this also raises a runtime error as X isn't a class name fun X:xxx() { ##ERROR: exception not handled - "not class" return self } --- ## this must not be very useful as Array is an index item ## and the clase instantiation method can't specify the size ## you can't place an item in the arrya at all. fun Array:*boom() { core.basicAtPut self 0 10 ##ERROR: exception not handled - "position(0) out of range - negative or greater than or equal to 0" printf "%O" self return self } Array:boom --- class X [ a b c ] { fun :* new () { self.a := 20 return self } fun getA() { return self.a } } ## the instance variables are not accessible in out-of-class method ## defintionas there isn't a good way to know the class structure ## as X isn't known in advance and can point to anything fun X:get_a() { return self.a ##ERROR: syntax error - not allowed to prefix with self } printf "%d\n" ((X:new):get_a) --- class F [ a b c ] { } class X [ a b c ] { fun oh() { fun F:get_a() { return super.a ##ERROR: syntax error - not allowed to prefix with super } } } --- class F { } class F { ##ERROR: exception not handled - "prohibited redefintion of F } --- class F { } F := 30 ##ERROR: exception not handled - "prohibited redefintion of F --- class F { } F := (class { ##ERROR: exception not handled - "prohibited redefintion of F" }) --- F := (class { }) F := (class F { ##ERROR: exception not handle - "prohibited redefintion of F" }) ## TDOO: do we need to allow the above? ##F := 30 ##class F { ##ERROR: exception not handled - "prohibited redefintion of F" ##}