blob: 989614fd338d2229ec3e6af7fea8f48284c20f0f (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
Sigils for mutabilty and arena access
=====================================
Sigils for mutability and arena access:
! for writable/mutable access
@ for arena access
@~ for arena+own access (destructor)
Syntax 1:
arena Thing obj = .new(other@)
obj.work@(123, result!)
obj.field! += 123
Syntax 2:
arena Thing obj = .new(other@)
obj@.work(123, result!)
obj!.field += 123
- Easiest to implement?
- Makes it clearer that "obj" is being modified.
- More consistent syntax
How about write-only?
Add a different sigil for this? Syntax?
obj!! obj!& obj!$
obj!~ obj!%
Or use obj! for write-only and obj!! for read-write?
- but reads are necessary when accessing thing inside fields,
even if nothing is "read" on the "high-level".
- allow "write-only" to read
- "output" vs "write-only"
Alternative solution:
- Don't use sigils, and let "the IDE" color objects differently
depending on how they are accessed (read-only, read-write or arena)
- Requires improving some existing IDE or writing a new one :(
- Bad for people who don't want to use an IDE.
Sigils for types
----------------
Should sigils be used for types also, instead of var/arena/own/etc?
- In that case, should "ref" still be used?
Syntax idea 1:
ref Thing! t
ref Thing@ t
ref! Thing t
t.modify!()
t.dostuff@()
f!()
Syntax idea 2:
ref !Thing t
ref @Thing t
!ref Thing t
t.!modify()
t.@dostuff()
!f()
Syntax idea 3:
ref Thing= t
ref Thing@ t
ref= Thing t
t.=modify()
t.@dostuff()
=f()
Syntax idea 4:
ref Thing= t
ref Thing@ t
ref= Thing t
t.modify=()
t.dostuff@()
f=()
|