blob: 7a602b4ff73de2ec91d7960376077ff454bd55e1 (
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
|
Constructors
------------
func new(arena a) -> ref var Thing
lifetime return == a # <-- an "==" relation needs to be added
{
ref var Thing obj = alloc{.x=123, .y=true} # <-- an "alloc" keyword needs to be added
obj.init_stuff()
return obj
}
The "alloc" keyword
-------------------
Allocation in the "default" arena (of the "this" parameter,
or in non-methods, of the first parameter):
ref var Thing t = alloc #<-- unintialized allocation
ref var Thing t = alloc {.x=123, .y=true} #<-- initialized struct alloc
ref var [4]int = alloc [1,2,3,4] #<-- initialized array alloc
Allocation in an explicit arena:
ref var Thing t = alloc ar
ref var Thing t = alloc ar {.x=123, .y=true}
ref var [4]int = alloc ar [1,2,3,4]
Parsing:
* No newline is allowed before the ( { [
|