Diff
Not logged in

Differences From Artifact [a04d420215bb851f]:

To Artifact [5f72922a0ac6e212]:


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