aboutsummaryrefslogtreecommitdiff
path: root/notes/class_kinds_keywords.txt
blob: 279507d4118ae782d77507bea189fe5506a77fe0 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

Are there only 3 (4?) kinds?
----------------------------

* struct
* abstract struct <-- is this necessary
* concrete class with identity
* abstract class


Separate keywords or multiple "flag keywords"?
----------------------------------------------
Examples of keywords:

* value         - value type
* identity      - type with identity (always passed by reference)
* abstract      - abstract/interface/trait
* concrete      - concrete/leaf class
* mutable       - has modifiable fields

Examples with flags on same line:

    type value abstract Property of T
    type identity abstract InputStream
    type identity concrete createonly FileInputStream implements InputStream

Examples with flags on separate lines:

    type Property of T
    value
    abstract

    type InputStream
    identity
    abstract

    type FileInputStream
    implements InputStream
    identity
    concrete
    createonly

Examples with flags on separate lines with prefix keyword:

    type Property of T
    typemode value
    typemode abstract

    type InputStream
    typemode identity
    typemode abstract

    type FileInputStream
    implements InputStream
    typemode identity
    typemode concrete
    typemode createonly

Separate keywords examples:

            |  Abstract         Concrete      |
  ----------+---------------------------------+
   Value    |  form             record        |
   Identity |  trait            class         |
  ----------+---------------------------------+

            |  Abstract         Concrete      |
  ----------+---------------------------------+
   Value    |  form             struct        |
   Identity |  interface        class         |
  ----------+---------------------------------+

Or, have "identity" as a (built-in) interface:

    class Point
    class File implements Identity

Also, ref vs aliased vs embedded:
* maybe ref-ness could be decided by the compiler?
* aliased/non-aliased and linked/embedded, however, affect behavior.    

Problems
--------
With this system, only leaf classes can be assumed to have / not have an
identity. So only leaf classes can be copied.

Maybe there's another way?

    record = immutable unless concrete and "owned" and not aliased?
    class = possibly mutable, can be aliased?

How to prevent mistakes
-----------------------
Incorrectly specifying a type as a value type can cause problems if
there's at least one mutable field