Diff
Not logged in

Differences From Artifact [a04d420215bb851f]:

To Artifact [5f72922a0ac6e212]:


61 if @type(x)=="RE" || @type(y)=="RE": "RE" 61 if @type(x)=="RE" || @type(y)=="RE": "RE" 62 else if @type(x)=="TE" || @type(y)=="TE": "TE" 62 else if @type(x)=="TE" || @type(y)=="TE": "TE" 63 else t0 63 else t0 64 )} 64 )} 65 }; 65 }; 66 66 67 # type annotation for built-in ops 67 # type annotation for built-in ops 68 @type "+" = Tbin("int", "int", "int"); | 68 @type + = Tbin("int", "int", "int"); 69 @type "-" = Tbin("int", "int", "int"); | 69 @type - = Tbin("int", "int", "int"); 70 @type "*" = Tbin("int", "int", "int"); | 70 @type * = Tbin("int", "int", "int"); 71 @type "/" = Tbin("int", "int", "int"); | 71 @type / = Tbin("int", "int", "int"); 72 @type "%" = Tbin("int", "int", "int"); | 72 @type % = Tbin("int", "int", "int"); 73 @type "&&" = Tbin("int", "int", "int"); | 73 @type && = Tbin("int", "int", "int"); 74 @type "||" = Tbin("int", "int", "int"); | 74 @type || = Tbin("int", "int", "int"); 75 @type print = fun(x){x}; 75 @type print = fun(x){x}; 76 @type gensym = fun(){"str"}; 76 @type gensym = fun(){"str"}; 77 @type argv = {list: "str"}; 77 @type argv = {list: "str"}; 78 @type rand = Tuni("int","int"); 78 @type rand = Tuni("int","int"); 79 @type "~" = Tbinany("str"); | 79 @type ~ = Tbinany("str"); 80 @type "<" = Tbinany("int"); | 80 @type < = Tbinany("int"); 81 @type "<=" = Tbinany("int"); | 81 @type <= = Tbinany("int"); 82 @type ">" = Tbinany("int"); | 82 @type > = Tbinany("int"); 83 @type ">=" = Tbinany("int"); | 83 @type >= = Tbinany("int"); 84 @type "==" = Tbinany("int"); | 84 @type == = Tbinany("int"); 85 @type "!=" = Tbinany("int"); | 85 @type != = Tbinany("int"); 86 @type "if" (c,t,e) {@value( | 86 @type if (c,t,e) {@value( 87 if @type(c)=="RE": "RE" 87 if @type(c)=="RE": "RE" 88 else if @type(c)!="int": "TE" 88 else if @type(c)!="int": "TE" 89 else mergeType( @type(t()), @type(e()) ); 89 else mergeType( @type(t()), @type(e()) ); 90 )}; 90 )}; 91 @type _isint = Tuniany("int"); 91 @type _isint = Tuniany("int"); 92 @type _isstr = Tuniany("int"); 92 @type _isstr = Tuniany("int"); 93 @type _isfun = Tuniany("int"); 93 @type _isfun = Tuniany("int"); ................................................................................................................................................................................ 94 @type _istbl = Tuniany("int"); 94 @type _istbl = Tuniany("int"); 95 @type _isbot = Tuniany("int"); 95 @type _isbot = Tuniany("int"); 96 96 97 ################################### 97 ################################### 98 98 99 # for lists 99 # for lists 100 @type "{}"() {@value( {list: "RE"} )}; 100 @type "{}"() {@value( {list: "RE"} )}; 101 @type ".?"(t, s) {@value( | 101 @type .? (t, s) {@value( 102 if @type(t)=="RE": "RE" 102 if @type(t)=="RE": "RE" 103 else if @type(t)=="TE": "TE" 103 else if @type(t)=="TE": "TE" 104 else if _istbl( @type(t) ): "int" 104 else if _istbl( @type(t) ): "int" 105 else "TE" 105 else "TE" 106 )}; 106 )}; 107 @type ".="(t, s@value, v) {@value( | 107 @type .= (t, s@value, v) {@value( 108 var tt = @type(t); 108 var tt = @type(t); 109 if tt == "TE": "TE" 109 if tt == "TE": "TE" 110 else if tt == "RE": "RE" 110 else if tt == "RE": "RE" 111 else if _istbl(tt) && tt.?list: 111 else if _istbl(tt) && tt.?list: 112 if s == "car": 112 if s == "car": 113 mergeType(tt, {list: @type(v)}) 113 mergeType(tt, {list: @type(v)}) 114 else if s == "cdr": 114 else if s == "cdr": 115 mergeType(tt, @type(v)) 115 mergeType(tt, @type(v)) 116 else: 116 else: 117 tt 117 tt 118 else: 118 else: 119 "TE" 119 "TE" 120 )}; 120 )}; 121 @type "."(t, s@value) {@value( | 121 @type . (t, s@value) {@value( 122 var tt = @type(t); 122 var tt = @type(t); 123 if tt == "TE": "TE" 123 if tt == "TE": "TE" 124 else if tt == "RE": "RE" 124 else if tt == "RE": "RE" 125 else if _istbl(tt) && tt.?list: 125 else if _istbl(tt) && tt.?list: 126 if s == "car": 126 if s == "car": 127 tt.list 127 tt.list 128 else if s == "cdr": 128 else if s == "cdr":