diff options
Diffstat (limited to 'test.toc')
-rw-r--r-- | test.toc | 78 |
1 files changed, 42 insertions, 36 deletions
@@ -1,45 +1,51 @@ -// puti @= fn(x: int) { -// #C("printf(\"%ld\\n\", (long)x); -// "); +// // puti @= fn(x: int) { +// // #C("printf(\"%ld\\n\", (long)x); +// // "); +// // }; +// // putf @= fn(x: float) { +// // #C("printf(\"%f\\n\", (double)x); +// // "); +// // }; + +// Arr @= fn (t @ Type) Type { +// struct { +// data : t; +// // len, cap : u64; +// } // }; -// putf @= fn(x: float) { -// #C("printf(\"%f\\n\", (double)x); -// "); + +// // todo: test that t @ type doesn't cause problems +// arr_add @= fn(t @ Type, a : &Arr(t)) { +// // if a.len >= a.cap { +// // a.cap = a.cap * 2 + 2; +// // new_data := new(t, a.cap); +// // each i := 0..a.len { +// // new_data[i] = a.data[i]; +// // } +// // a.data = new_data; +// // } +// // a.data[a.len] = x; +// // a.len += 1; // }; -Arr @= fn (t @ Type) Type { - struct { - data : t; - // len, cap : u64; - } -}; -// todo: test that t @ type doesn't cause problems -arr_add @= fn(t @ Type, a : &Arr(t)) { - // if a.len >= a.cap { - // a.cap = a.cap * 2 + 2; - // new_data := new(t, a.cap); - // each i := 0..a.len { - // new_data[i] = a.data[i]; - // } - // a.data = new_data; - // } - // a.data[a.len] = x; - // a.len += 1; -}; +// main @= fn() { +// // arr : Arr(int); +// // // arr_add(int, &arr, 5); +// // // arr_add(int, &arr, 10); +// // // arr_add(int, &arr, 20); +// // // each i := 0..arr.len - 1 { +// // // puti(arr.data[i]); +// // // } +// }; + +// // t @= fn(x @ Type) Type { struct { t: x; } }; +// // // pass the wrong thing to t, and the error is in the wrong place +// // f @= fn(x: t(int)) {}; -main @= fn() { -// arr : Arr(int); -// // arr_add(int, &arr, 5); -// // arr_add(int, &arr, 10); -// // arr_add(int, &arr, 20); -// // each i := 0..arr.len - 1 { -// // puti(arr.data[i]); -// // } +f @= fn(t @ Type, x : t) { }; -// t @= fn(x @ Type) Type { struct { t: x; } }; -// // pass the wrong thing to t, and the error is in the wrong place -// f @= fn(x: t(int)) {};
\ No newline at end of file +main @= fn() { f(int, 3); };
\ No newline at end of file |