Skip to content

Commit 1686e41

Browse files
committed
Update: simplify terse syntax further by omitting -> too
And use it in test cases See discussion #714
1 parent f079198 commit 1686e41

11 files changed

+49
-135
lines changed

regression-tests/pure2-more-wildcards.cpp2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

2-
less_than: (value:_) -> _ =
3-
:(x:_) -> _ = x < value$;
2+
less_than: (value) :(x) x < value$;
43

54
main: () -> int
65
= {

regression-tests/pure2-template-parameter-lists.cpp2

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11

2-
f1: <T, U> (t:T, u:U) -> _ = {
3-
return t+u;
4-
}
5-
6-
f2: <T:type, U:type> (t:T, u:U) -> _ = {
7-
return t+u;
8-
}
9-
10-
f3: <T:_, U:_> () -> _ = {
11-
return T+U;
12-
}
13-
14-
f4: <T: i8, U: i16> () -> _ = {
15-
return T+U;
16-
}
2+
f1: <T, U> (t:T, u:U) t+u;
3+
f2: <T:type, U:type> (t:T, u:U) t+u;
4+
f3: <T:_, U:_> () T+U;
5+
f4: <T: i8, U: i16> () T+U;
176

187
main: () = {
198
std::cout << "f1: (f1(1,1))$\n";

regression-tests/pure2-types-basics.cpp2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ myclass : type = {
5454
g: () = std::cout << "N::myclass::nested::g\n";
5555
}
5656

57-
f1: <T , U > (t:T, u:U) -> _ = t+u;
58-
f2: <T:type, U:type> (t:T, u:U) -> _ = t+u;
59-
f3: <T:_ , U:_ > () -> _ = T+U;
60-
f4: <T:i8 , U:i16 > () -> _ = T+U;
57+
f1: <T , U > (t:T, u:U) t+u;
58+
f2: <T:type, U:type> (t:T, u:U) t+u;
59+
f3: <T:_ , U:_ > () T+U;
60+
f4: <T:i8 , U:i16 > () T+U;
6161

6262
}
6363

regression-tests/pure2-variadics.cpp2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ all: <Args...: type> (args...: Args) -> bool =
1313
// Unary left fold expression
1414
(... && args);
1515

16-
make_string: <Args...: type> (forward args...: Args) -> _ = :std::string = args...;
16+
make_string: <Args...> (forward args...: Args) :std::string = args...;
1717

18-
make: <T, Args...: type> (forward args...: Args) -> _ = :T = args...;
18+
make: <T, Args...> (forward args...: Args) :T = args...;
1919

2020
main: ()
2121
= {

regression-tests/test-results/pure2-more-wildcards.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#line 2 "pure2-more-wildcards.cpp2"
1515
[[nodiscard]] auto less_than(auto const& value) -> auto;
16-
1716

1817
[[nodiscard]] auto main() -> int;
1918

@@ -22,8 +21,7 @@
2221

2322

2423
#line 2 "pure2-more-wildcards.cpp2"
25-
[[nodiscard]] auto less_than(auto const& value) -> auto {
26-
return [_0 = value](auto const& x) -> auto { return cpp2::cmp_less(x,_0); }; }
24+
[[nodiscard]] auto less_than(auto const& value) -> auto { return [_0 = value](auto const& x) -> auto { return cpp2::cmp_less(x,_0); }; }
2725

2826
[[nodiscard]] auto main() -> int
2927
{

regression-tests/test-results/pure2-template-parameter-lists.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,21 @@
1313

1414
#line 2 "pure2-template-parameter-lists.cpp2"
1515
template<typename T, typename U> [[nodiscard]] auto f1(T const& t, U const& u) -> auto;
16-
17-
18-
#line 6 "pure2-template-parameter-lists.cpp2"
1916
template<typename T, typename U> [[nodiscard]] auto f2(T const& t, U const& u) -> auto;
20-
21-
22-
#line 10 "pure2-template-parameter-lists.cpp2"
2317
template<auto T, auto U> [[nodiscard]] auto f3() -> auto;
24-
25-
26-
#line 14 "pure2-template-parameter-lists.cpp2"
2718
template<cpp2::i8 T, cpp2::i16 U> [[nodiscard]] auto f4() -> auto;
28-
2919

30-
#line 18 "pure2-template-parameter-lists.cpp2"
3120
auto main() -> int;
3221

3322

3423
//=== Cpp2 function definitions =================================================
3524

3625

3726
#line 2 "pure2-template-parameter-lists.cpp2"
38-
template<typename T, typename U> [[nodiscard]] auto f1(T const& t, U const& u) -> auto{
39-
return t + u;
40-
}
41-
42-
template<typename T, typename U> [[nodiscard]] auto f2(T const& t, U const& u) -> auto{
43-
return t + u;
44-
}
45-
46-
template<auto T, auto U> [[nodiscard]] auto f3() -> auto{
47-
return T + U;
48-
}
49-
50-
template<cpp2::i8 T, cpp2::i16 U> [[nodiscard]] auto f4() -> auto{
51-
return T + U;
52-
}
27+
template<typename T, typename U> [[nodiscard]] auto f1(T const& t, U const& u) -> auto { return t + u; }
28+
template<typename T, typename U> [[nodiscard]] auto f2(T const& t, U const& u) -> auto { return t + u; }
29+
template<auto T, auto U> [[nodiscard]] auto f3() -> auto { return T + U; }
30+
template<cpp2::i8 T, cpp2::i16 U> [[nodiscard]] auto f4() -> auto { return T + U; }
5331

5432
auto main() -> int{
5533
std::cout << "f1: " + cpp2::to_string(f1(1, 1)) + "\n";

regression-tests/test-results/pure2-types-basics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace N {
182182

183183
#line 57 "pure2-types-basics.cpp2"
184184
template<typename T, typename U> [[nodiscard]] auto myclass::f1(T const& t, U const& u) -> auto { return t + u; }
185-
template<typename T, typename U> [[nodiscard]] auto myclass::f2(T const& t, U const& u) -> auto { return t + u; }
185+
template<typename T, typename U> [[nodiscard]] auto myclass::f2(T const& t, U const& u) -> auto { return t + u; }
186186
template<auto T, auto U> [[nodiscard]] auto myclass::f3() -> auto { return T + U; }
187187
template<cpp2::i8 T, cpp2::i16 U> [[nodiscard]] auto myclass::f4() -> auto { return T + U; }
188188

regression-tests/test-results/pure2-variadics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ template<typename ...Args> [[nodiscard]] auto all(Args const& ...args) -> bool;
3333

3434

3535
#line 16 "pure2-variadics.cpp2"
36-
template<typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto;
36+
template <typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto;
3737

38-
template<typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto;
38+
template <typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto;
3939

4040
auto main() -> int;
4141

@@ -53,9 +53,9 @@ template<typename ...Args> [[nodiscard]] auto all(Args const& ...args) -> bool {
5353
// Unary left fold expression
5454
return (... && args); }
5555

56-
template<typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto { return std::string{CPP2_FORWARD(args)...}; }
56+
template <typename ...Args> [[nodiscard]] auto make_string(Args&& ...args) -> auto { return std::string{CPP2_FORWARD(args)...}; }
5757

58-
template<typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto { return T{CPP2_FORWARD(args)...}; }
58+
template <typename T, typename ...Args> [[nodiscard]] auto make(Args&& ...args) -> auto { return T{CPP2_FORWARD(args)...}; }
5959

6060
auto main() -> int
6161
{

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8930:1743
2+
cppfront compiler v0.2.1 Build 8A01:0916
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8930:1743"
1+
"8A01:0916"

0 commit comments

Comments
 (0)