言語ゲーム

とあるエンジニアが嘘ばかり書く日記

Twitter: @propella

Joy から S 式を生成する。

本当にどうでも良い話だが、かっこいいトレースが出来たのでコピペ。Joy のようですでに Joy で無くなりつつある自作言語の意味ツリーを S 式のような記法で出力してゆく様子。y:= はセッター、:y はゲッターでこの部分で Smalltalk と通信します。ツリーの中では副作用が起こらないので、いわば IO モナドの働きをします。

'acc' get 0.2 + dup 'y' get swap - 'y' set swap 'acc'  set
10 'x' get + 'x' set
> 'acc'  :: get 0.2 + dup 'y' get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> :acc  :: 0.2 + dup 'y' get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> :acc 0.2  :: + dup 'y' get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 )  :: dup 'y' get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (+ :acc 0.2 )  :: 'y' get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (+ :acc 0.2 ) 'y'  :: get swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (+ :acc 0.2 ) :y  :: swap - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) :y (+ :acc 0.2 )  :: - 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (- :y (+ :acc 0.2 ) )  :: 'y' set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (- :y (+ :acc 0.2 ) ) 'y'  :: set swap 'acc' set 10 'x' get + 'x' set 
> (+ :acc 0.2 ) (y:= (- :y (+ :acc 0.2 ) ))  :: swap 'acc' set 10 'x' get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (+ :acc 0.2 )  :: 'acc' set 10 'x' get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (+ :acc 0.2 ) 'acc'  :: set 10 'x' get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 ))  :: 10 'x' get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) 10  :: 'x' get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) 10 'x'  :: get + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) 10 :x  :: + 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) (+ 10 :x )  :: 'x' set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) (+ 10 :x ) 'x'  :: set 
> (y:= (- :y (+ :acc 0.2 ) )) (acc:= (+ :acc 0.2 )) (x:= (+ 10 :x ))  ::