blob: 2dbd10ffca9b4467cd7c824f91fde3f696899e57 (
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
|
Syntax for defining constructors
================================
Syntax option 1:
# default constructor name should be `new`
# if omitted, a default constructor should be created (similar to Java)
constructor
code
field = 123
end
# name can be overridden
constructor new_with_value
int value
code
field = value
end
Syntax option 2:
func :new
code
field = 123
end
func :with_value
int value
code
field = value
end
Other things to decide:
* Should `new` be a keyword or an identifier?
- An identifier is more logical (because it can be overridden)
- But a keyword would prevent it from being used as a function,
field or enum name.
- Could forbid `new` and `new_`... in other places.
(It's not just `new` anyway)
* Type-identifiers:
- `new` and `new_`... could be special and trigger a typeident search?
- Or maybe just `:xxx`
|