blob: de5443455ea51291044afc4448cbaf4c7c205f6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
Data declarations with types with {} are hard to read:
var struct {
int a
bool b
} thing = (0, false)
var enum {
a
b
} choice
Alternative solutions:
1:
var + thing = (0, false)
\ struct {
int a
bool b
}
2:
given type T = struct {
int a
bool b
} var T thing = (0, false)
3:
where type T = struct {
int a
bool b
} var T thing = (0, false)
4:
var ... thing = (0, false)
struct {
int a
bool b
}
"where" blocks could be useful for local macros:
where {
data int a = 1
type Pair = struct {
SomeLongType<Xxxx,Yyyy> a
ref SomeOtherLongType<Xxxx> b
}
} in {
...
}
And also for function definitions with struct paramters:
where {
type Pair = struct {
SomeLongType<Xxxx,Yyyy> a
ref SomeOtherLongType<Xxxx> b
}
} in {
func do_stuff(ref Pair a, ref Pair b)
}
- in this case, the Pair type should work like an anonymous type.
- this makes it harder to grep for functions (can start at column != 1).
but the "in { }" part could be avoided, and it could apply only to
the following line.
|