: Mops ( オブジェクト指向FORTH -- ) ;
■ このスレッドは過去ログ倉庫に格納されています
0108名無しさん@Emacs
NGNGがサンプルとして入っている。
ftp://ftp.forth.org/pub/Forth/Compilers/native/unix/tile-forth-2.1.tar.z
message position ( x y self -- )
message write ( self -- )
message read ( self -- )
Object subclass Point ( x y -- )
long +x ( self -- addr)
long +y ( self -- addr)
method initiate ( x y self -- )
dup >r super initiate r> position
;
method position ( x y self -- )
tuck +y ! +x !
;
method where ( self -- x y)
dup +x @ swap +y @
;
method write ( self -- )
dup super write where ." x: " swap . ." :y " .
;
subclass.end
10 10 Point instance aPoint
aPoint write cr
-10 -10 aPoint position
aPoint write cr
aPoint read
cr
こんな感じ。
■ このスレッドは過去ログ倉庫に格納されています