moof2-example.fs 332 Bytes
Newer Older
Bernd Paysan's avatar
Bernd Paysan committed
1 2 3 4 5
\ Mini-OOF2 example

require mini-oof2.fs

object class
6 7
    field: x
    field: y
Bernd Paysan's avatar
Bernd Paysan committed
8 9 10 11 12
    method p@
    method p!
    method p.
end-class point

13 14 15
:noname x @ y @ ; point to p@
:noname x ? y ? ; point to p.
:noname y ! x ! ; point to p!
Bernd Paysan's avatar
Bernd Paysan committed
16 17 18

point new Constant p1
p1 >o 1 2 p! o>
19 20 21
p1 >o p. o> cr
: test p1 >o 1 2 p! p. x @ y @ + . o> ;
test cr