Differences From Artifact [c9a55d8e7b3293ae]:
- File
sample/type.pmy
- 2010-11-13 12:16:47 - part of checkin [5afe8e3f26] on branch trunk - Memoization on non "@v" layer. Now simplest metalevel computation works!! Also, added -l option. (user: kinaba) [annotate]
To Artifact [ed44c7901d3c5853]:
- File
sample/type.pmy
- 2010-11-21 15:48:16 - part of checkin [f86026acb8] on branch trunk - macro cache and automemoization reloaded. auto re-run implemented. but automemo and autorerun is currently disabled. we need Table.opCmp... we also need to think more about the memoization (user: kinaba) [annotate]
3 3 else { if( _isstr(x) ) { "str" }
4 4 else { if( _isfun(x) ) { x }
5 5 else { if( _isundefined(x) ) { "undefined" }
6 6 else { "any" }}}}
7 7 };
8 8
9 9 def binop(a,b,c) {
10 - fun(x,y){@v(
10 + fun(x,y){@value(
11 11 if( @type(x)=="undefined" || @type(y)=="undefined" ) { "undefined" } else {
12 12 if( @type(x)==a && @type(y)==b ) { c } else { "error" }
13 13 }
14 14 )}
15 15 };
16 16
17 17 @type "+" = binop("int", "int", "int");
................................................................................
19 19 @type "<" = binop("int", "int", "int");
20 20 @type ">" = binop("int", "int", "int");
21 21
22 22 def mergeType(a,b) {
23 23 if( a == "undefined" ) { if(b=="undefined"){"error"}else{b} } else { a }
24 24 };
25 25
26 -@type "if" = fun(c,t,e) {@v(
26 +@type "if" = fun(c,t,e) {@value(
27 27 if(@type(c)=="int" ) { mergeType(@type(t()), @type(e())) } else { "error" }
28 28 )};