@@ -321,9 +321,9 @@ 他のレイヤで動かしてみましょう。適当に。「@hoge レイヤ」で。
>> @hoge( 3 ) - polemy.failure.RuntimeException@C:\Develop\Projects\Polemy\polemy\eval.d(138): + polemy.failure.RuntimeException@polemy\eval.d(138): [:4:8] lift function for @hoge is not registered
エラーになりました。Polemy のインタプリタは、起動時には、@value @@ -353,9 +353,9 @@ では、1+2 を @hoge レイヤで動かしてみましょう。
>> @hoge( 1 + 2 ) - polemy.failure.RuntimeException@C:\Develop\Projects\Polemy\polemy\eval.d(466): + polemy.failure.RuntimeException@polemy\eval.d(466): [:3:7] only @value layer can call native function: + [ :3:7] +
@@ -362,9 +362,9 @@ まだエラーですね。これは要するに "+" の意味がわからない、と言っています。 $(RED $(B レイヤ指定変数定義式)) で、"+" の意味を教えてあげます。
- >> @hoge "+" = fun(x, y) {x} + >> @hoge + = fun(x, y) {x} (function:182eca0:18435e0) >> @hoge( 3 + 4 ) 6@@ -375,12 +375,12 @@ 他の組み込み関数の意味も決めてみましょう。この @hoge レイヤでは、 引き算のつもりで書いたコードが、掛け算になってしまうのだ!
- >> @hoge "-" = fun(x, y) {x * y} + >> @hoge - = fun(x, y) {x * y} (function:1b4c6a0:1b4fbe0) >> @hoge( 5 - 6 ) - polemy.failure.RuntimeException@C:\Develop\Projects\Polemy\polemy\eval.d(469): + polemy.failure.RuntimeException@polemy\eval.d(469): [@@ -395,9 +395,9 @@ この部分については、@value レイヤで計算して欲しい。 そんなときは、レイヤ指定式を使います。:3:24] only @value layer can call native function: * [ :3:24] * [ :4:8] -
- >> @hoge "-" = fun(x, y) {$(B @value(@hoge(x) * @hoge(y)))} + >> @hoge - = fun(x, y) {$(B @value(@hoge(x) * @hoge(y)))} (function:1b086c0:1b4fbe0) >> @hoge( 5 - 6 ) 120@@ -556,11 +556,11 @@ else if tx=="int" && ty=="int" then "int" else "type error" )}; - @type "+" = int_int_int; - @type "-" = int_int_int; - @type "<" = int_int_int; + @type + = int_int_int; + @type - = int_int_int; + @type < = int_int_int;
>> @type( 1 + 2 ) int @@ -572,9 +572,9 @@ ここではしています。さらに(ちょっと手抜きで int 以外を考えていない)if の型定義を考えると、 こんな雰囲気。- @type "if" (c, t, e) {@value( + @type if (c, t, e) {@value( if( @type(c)=="int" || @type(c)=="runtime error" ) then @type( int_int_int(t(), e()) ) else "type error" @@ -799,9 +799,9 @@ これはエラーになります。>> let _ = (@macro twice(x) {x;x} in twice(print("Hello"))) - polemy.failure.RuntimeException@C:\Develop\Projects\Polemy\polemy\value.d(109): + polemy.failure.RuntimeException@polemy\value.d(109): [:2:35] 'twice' is not set in @value layer どういうことかというと、@macro で定義したマクロはいつから使えるようになるかという話で、