Index: doc/index.html ================================================================== --- doc/index.html +++ doc/index.html @@ -433,11 +433,11 @@ 3 他のレイヤで動かしてみましょう。適当に。「@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 レイヤでのコードの意味しか知りません。@hoge レイヤでは 3 @@ -465,20 +465,20 @@
では、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] +
まだエラーですね。これは要するに "+" の意味がわからない、と言っています。 レイヤ指定変数定義式 で、"+" の意味を教えてあげます。
- >> @hoge "+" = fun(x, y) {x}
+ >> @hoge + = fun(x, y) {x}
(function:182eca0:18435e0)
>> @hoge( 3 + 4 )
6
@@ -487,14 +487,14 @@
他の組み込み関数の意味も決めてみましょう。この @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):
[:3:24] only @value layer can call native function: *
[:3:24] *
[:4:8] -
@@ -507,11 +507,11 @@ ここは、「普通の」意味の掛け算を使いたいのです。 この部分については、@value レイヤで計算して欲しい。 そんなときは、レイヤ指定式を使います。
- >> @hoge "-" = fun(x, y) {@value(@hoge(x) * @hoge(y))}
+ >> @hoge - = fun(x, y) {@value(@hoge(x) * @hoge(y))}
(function:1b086c0:1b4fbe0)
>> @hoge( 5 - 6 )
120
@@ -708,13 +708,13 @@ else if ty=="runtime error" then tx 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
>> @type( 1 + "foo" )
@@ -724,11 +724,11 @@
「実行時エラーについては、それが起きなければ返すはずの型」を計算するという定義に、
ここではしています。さらに(ちょっと手抜きで 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"
)};
@@ -1011,11 +1011,11 @@
これはエラーになります。
>> 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 で定義したマクロはいつから使えるようになるかという話で、 この @macro twice(x) {x;x} in ... の部分は @value レイヤの式なので、 @@ -1160,11 +1160,11 @@
- on Tue Nov 30 10:23:12 2010
+ on Thu Dec 2 09:14:39 2010