From 2d58b4d95f492c5bcd8a219e34cc78b757dcfe8f Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 4 Apr 2019 13:15:12 +0200 Subject: [PATCH] :art: Remove 'template' keyword --- ast | 2 +- examples/binary_tmpl.gw | 2 +- examples/in_class_class.gw | 3 +-- examples/template.gw | 13 ++----------- examples/template_dyn.gw | 15 +++++---------- examples/template_guess.gw | 3 +-- examples/template_vararg.gw | 3 +-- tests/bug/Tester.gw | 6 ++---- tests/bug/template_no_guess.gw | 4 ---- tests/error/template_class_no_type.gw | 3 +-- tests/error/template_enough.gw | 3 +-- tests/error/template_n_mismatch.gw | 6 ++---- tests/error/template_no_match.gw | 6 ++---- tests/error/template_ternary.gw | 3 +-- tests/error/template_unknown.gw | 3 +-- tests/tree/class_template.gw | 3 +-- tests/tree/static_template.gw | 3 +-- tests/tree/template_class_ref.gw | 3 +-- tests/tree/template_typedef.gw | 2 +- 19 files changed, 26 insertions(+), 60 deletions(-) diff --git a/ast b/ast index fbd0bdbb..334325fa 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit fbd0bdbb2950dbfc8f62167c795390500d660cfa +Subproject commit 334325fab4ff94b04713e87a5b1be4cd0ff24574 diff --git a/examples/binary_tmpl.gw b/examples/binary_tmpl.gw index 60253182..34b11cc1 100644 --- a/examples/binary_tmpl.gw +++ b/examples/binary_tmpl.gw @@ -1,4 +1,4 @@ -template<~A~> fun void test(A a) { <<>>; } +fun<~A~> void test(A a) { <<>>; } 1 => test; 1.3 => test; test(1); diff --git a/examples/in_class_class.gw b/examples/in_class_class.gw index b0ab8768..3ef4deee 100644 --- a/examples/in_class_class.gw +++ b/examples/in_class_class.gw @@ -1,6 +1,5 @@ class C { - template<~a~> - function void test(a var){ <<>>; } + function<~a~> void test(a var){ <<>>; } class D { int i;} } diff --git a/examples/template.gw b/examples/template.gw index 23f8647e..d4d2dfc4 100644 --- a/examples/template.gw +++ b/examples/template.gw @@ -1,13 +1,4 @@ -template <~a~> -function void test (a var){ <<< var>>>; } -template <~a, b~> -function void test (a var, b var2){ <<< var>>>; } -//function void test (){ } - +function<~A~> void test (A var){ <<< var>>>; } +function<~A,B~> void test (A var, B var2){ <<< var>>>; } test<~int~>(1); -//test(1.4); -//test(3, 1.4); -//test(3); -//test(3, 1.4); test<~float, float~>(3, 1.4); -//test(3, 1.4); diff --git a/examples/template_dyn.gw b/examples/template_dyn.gw index ebfa2514..e5fe155f 100644 --- a/examples/template_dyn.gw +++ b/examples/template_dyn.gw @@ -4,20 +4,15 @@ fun void test(C cc, int i) { <<<1>>>; <<>>; } class C { - template<~A~> - fun int test(A a) { <<<" A ", a>>>; } - template<~A~> - fun int test(A a, int i) { <<<" ", a >>>; } - template<~A~> - fun int test(A a, int i, int j) { <<>>; } + fun<~A~> int test(A a) { <<<" A ", a>>>; } + fun<~A~> int test(A a, int i) { <<<" ", a >>>; } + fun<~A~> int test(A a, int i, int j) { <<>>; } } class D extends C { - template<~A~> - fun int test(A a, int i) { <<>>; } + fun int<~A~> test(A a, int i) { <<>>; } } class E extends D { - template<~A~> - fun int test(A a, int i) { <<>>; } + fun int<~A~> test(A a, int i) { <<>>; } } diff --git a/examples/template_guess.gw b/examples/template_guess.gw index 85d94084..f68ac1a3 100644 --- a/examples/template_guess.gw +++ b/examples/template_guess.gw @@ -1,5 +1,4 @@ -template <~A, B~> -function void test(A a, B b){<<>>;} +function void<~A,B~> test(A a, B b){<<>>;} test(1, 2.1); test(1.1, 2.1); test(1.2, 2); diff --git a/examples/template_vararg.gw b/examples/template_vararg.gw index d9914d32..77ad4f94 100644 --- a/examples/template_vararg.gw +++ b/examples/template_vararg.gw @@ -1,5 +1,4 @@ -template <~a~> -fun void test(...) { +fun<~A~> void test(...) { vararg.start; <<>>; vararg.end; diff --git a/tests/bug/Tester.gw b/tests/bug/Tester.gw index ee55739a..73a675d7 100644 --- a/tests/bug/Tester.gw +++ b/tests/bug/Tester.gw @@ -1,9 +1,7 @@ class Tester { - template<~A~> - function int assert_equal(string description, A a, A b){ if(a == b) return 0; return 1; } - template<~A~> - function int assert_not_equal(string description, A a, A b){ if(a != b) return 0; return 1; } + function<~A~> int assert_equal(string description, A a, A b){ if(a == b) return 0; return 1; } + function<~A~> int assert_not_equal(string description, A a, A b){ if(a != b) return 0; return 1; } } Tester t; diff --git a/tests/bug/template_no_guess.gw b/tests/bug/template_no_guess.gw index 03ef8747..c160b6f2 100644 --- a/tests/bug/template_no_guess.gw +++ b/tests/bug/template_no_guess.gw @@ -1,6 +1,2 @@ -//template <~a~> function void test(){} -//function void test(int i[]){<<>>;} -//function void test(Object o){} - test([1], 2.3); diff --git a/tests/error/template_class_no_type.gw b/tests/error/template_class_no_type.gw index d46f7745..fd81f4ed 100644 --- a/tests/error/template_class_no_type.gw +++ b/tests/error/template_class_no_type.gw @@ -1,6 +1,5 @@ // [contains] you must provide template types -template<~A~> -class C { +class<~A~> C { A a; } diff --git a/tests/error/template_enough.gw b/tests/error/template_enough.gw index 2fd7cc12..6261d084 100644 --- a/tests/error/template_enough.gw +++ b/tests/error/template_enough.gw @@ -1,4 +1,3 @@ // [contains] - template<~a, b~> -function void test(){} +function<~A,B~> void test(){} test(); diff --git a/tests/error/template_n_mismatch.gw b/tests/error/template_n_mismatch.gw index 44a74172..a5892457 100644 --- a/tests/error/template_n_mismatch.gw +++ b/tests/error/template_n_mismatch.gw @@ -1,8 +1,6 @@ // [contains] arguments do not match for template call -template <~i~> -function void test(){ <<<"func">>>;} -template <~i~> -function void test(int i){<<<"other func">>>;} +function<~A~> void test(){ <<<"func">>>;} +function<~A~> void test(int i){<<<"other func">>>;} test<~int, float, int~>(); //test<~int~>(); diff --git a/tests/error/template_no_match.gw b/tests/error/template_no_match.gw index 02ed2e53..08586135 100644 --- a/tests/error/template_no_match.gw +++ b/tests/error/template_no_match.gw @@ -1,9 +1,7 @@ // [contains] arguments do not match for template call class C { - template <~a~> - function void test(float f) {} - template <~a~> - function void test() {} + function<~A~> void test(float f) {} + function<~A~> void test() {} } C c; //c.test<~int~>(); diff --git a/tests/error/template_ternary.gw b/tests/error/template_ternary.gw index 79285532..86318b6a 100644 --- a/tests/error/template_ternary.gw +++ b/tests/error/template_ternary.gw @@ -1,5 +1,4 @@ // [contains] invalid expression for function call -template<~A~> -function void test(A a){} +function<~A~> void test(A a){} (maybe ? test : test)(1); diff --git a/tests/error/template_unknown.gw b/tests/error/template_unknown.gw index 85b4eaf0..503d7a3e 100644 --- a/tests/error/template_unknown.gw +++ b/tests/error/template_unknown.gw @@ -1,5 +1,4 @@ // [contains] unknown type - template<~my_type~> -function void my_function() { <<<"test">>>; } +function<~A~> void my_function() { <<<"test">>>; } my_function<~unknown_type~>(); diff --git a/tests/tree/class_template.gw b/tests/tree/class_template.gw index 225eb4e6..9501a315 100644 --- a/tests/tree/class_template.gw +++ b/tests/tree/class_template.gw @@ -5,8 +5,7 @@ class C { fun A test() { <<<"lol">>>; } - template<~C~> - fun void test2(C c) { + fun<~C~> void test2(C c) { <<>>; } } diff --git a/tests/tree/static_template.gw b/tests/tree/static_template.gw index 8b91a6cf..a7077e0c 100644 --- a/tests/tree/static_template.gw +++ b/tests/tree/static_template.gw @@ -1,5 +1,4 @@ -template <~A~> -class C { +class<~A~> C { A a; } diff --git a/tests/tree/template_class_ref.gw b/tests/tree/template_class_ref.gw index 96b9d109..263cc918 100644 --- a/tests/tree/template_class_ref.gw +++ b/tests/tree/template_class_ref.gw @@ -1,5 +1,4 @@ -template<~A~> -class C {} +class<~A~> C {} <~int~>C ref; <<>>; diff --git a/tests/tree/template_typedef.gw b/tests/tree/template_typedef.gw index 7f7dc189..a1565217 100644 --- a/tests/tree/template_typedef.gw +++ b/tests/tree/template_typedef.gw @@ -6,7 +6,7 @@ lol t; class C extends lol { int i;} C c; <<>>; -template <~A~> class D { +class<~A~> D { <<<"lol">>>; int i; } -- 2.43.0