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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
Pointers
========
Currently, SLUL has explicit pointers with the following properties:
- not nullable (unless ?ref)
- no access to the address (except dereferencing and comparing)
- can merge into generic slots ("slot T")
- can be compared.
Limiting pointers
-----------------
This could allow for optimizations AND possibly partially removing explicit
pointers in types.
- Disallow referencing a field inside a struct unless
this is explicitly allowed? This will reduce aliasing.
- Disallow referencing elementary types?
(except for output parameters? and only to the stack?)
- Disallow pointer comparison?
(unless the type explicitly allows it?)
There is a middle ground here:
- Allow only the following to be referenced:
1. all "outer" types, i.e. that are not part of a struct.
this includes both heap and stack allocations.
2. all named struct types.
i.e. struct fields that are of a named struct type can still be
referenced, despite not being an "outer" type.
- Then, elementary types can only be referenced when allocated
on the stack or when it constitutes a single heap allocation.
Implicit pointers
-----------------
Have different kinds of types?
- "plain data"
passed by reference if faster.
no unique objects / no identity per object.
no unique address.
no comparison operation.
- functions
always passed by reference.
no unique objects / no identity per object.
no unique address.
no comparison operation.
- "identity data"
always passed by reference.
never de-duplicated.
address can be compared to objects of the same type.
- "system data" (e.g. streams, locks, etc)
always passed by reference.
never de-duplicated.
address can be compared to objects of the same type.
needs de-allocation.
For "plain data" it could make sense to include them inline in a struct.
Default-ref / Explicit copy
---------------------------
Maybe it is better to explicitly specify when something is NOT a pointer
(i.e. is copied)?
The downside is that "arena" and "own" still need qualifiers.
(Perhaps "arena" could be default in some contexts? e.g. local variables?)
Current syntax, with ref:
Point p = (1,2)
arena Stream input = .from_string("abc")
ref Matrix m = .[.[1,0,0], .[0,1,0], .[0,0,1]]
Syntax with "inverted" syntax:
value Point p = (1,2)
arena Stream input = .from_string("abc")
Matrix m = .[.[1,0,0], .[0,1,0], .[0,0,1]]
Perhaps there should be a default for each type?
Perhaps sigills (e.g. "@") should be used instead of the arena
keyword?
|