@@ -67,63 +67,61 @@ The following principles guide a lot of the design decisions made with
67
67
regard to 6model, and are a good starting point for understanding why
68
68
it is structured the way it is.
69
69
70
- =over 4
71
-
72
- =item Minimal, non-commital core: out of the box, 6model provides very
73
- minimal object oriented functionality . It provides one meta-object that
74
- implements objects with attributes (state) and methods (behavior) - and
75
- that's about it. It doesn't enforce one definition of method dispatch,
76
- inheritance, interfaces, introspection and so forth. These are all built
77
- up by implementing meta-objects that specify their semantics.
78
-
79
- =item Representation polymorphism: rather than committing to one view of
80
- how to lay out an object in memory, 6model supports "representations".
81
- Representations define how attributes are actually stored and accessed,
82
- how primitive types (integers, floating point values and strings) are
83
- boxed and unboxed - or perhaps both. Additionally, representations are
84
- orthogonal to meta-objects, meaning it is possible to define one type
85
- (e.g. a class) and use it with different storage stratergies .
86
-
87
- =item Gradual typing support: 6model tries to provide ways to pick points
88
- on the static-dynamic typing scale. For languages that themselves support
89
- gradual typing, this is directly useful. However, it means that one could
90
- implement object models that are completely dynamic or completely static.
91
- Objects where method calls are dispatched by a fast lookup in a v-table
92
- are just as possible as objects where method calls dynamically build a
93
- call to a web service.
94
-
95
- =item Portable between virtual machines: by using 6model, it should
96
- become easier to make a compiler that is portable between VMs. Currently
97
- 6model implementations in varying states of completeness exist on Parrot,
98
- the .Net CLR and the JVM.
99
-
100
- =item Meta-objects are authoritative: in an ideal world, every single
101
- method dispatch we perform would be conducted by delegating to the
102
- meta-object's method that implements method dispatch semantics. In the
103
- real world, that's not practical from a performance point of view. Thus
104
- 6model provides various mechanisms that a meta-object can "opt in" to in
105
- order to allow for muchly increased performance. However, it considers all
106
- of these to really just be a kind of "cache". A v-table is just an array
70
+ =head3 Minimal, non-commital core
71
+ Out of the box, 6model provides very minimal object oriented functionality.
72
+ It provides one meta-object that implements objects with attributes (state)
73
+ and methods (behavior) - and that's about it . It doesn't enforce one
74
+ definition of method dispatch, inheritance, interfaces, introspection and
75
+ so forth. These are all built up by implementing meta-objects that specify
76
+ their semantics.
77
+
78
+ =head3 Representation polymorphism
79
+ Rather than committing to one view of how to lay out an object in memory,
80
+ 6model supports "representations". Representations define how attributes are
81
+ actually stored and accessed, how primitive types (integers, floating point
82
+ values and strings) are boxed and unboxed - or perhaps both. Additionally,
83
+ representations are orthogonal to meta-objects, meaning it is possible to
84
+ define one type (e.g. a class) and use it with different storage stratergies.
85
+ This is known as representation polymorphism .
86
+
87
+ =head3 Gradual typing support
88
+ 6model tries to provide ways to pick points on the static-dynamic typing scale.
89
+ For languages that themselves support gradual typing, this is directly useful.
90
+ However, it means that one could implement object models that are completely
91
+ dynamic or completely static. Objects where method calls are dispatched by a
92
+ fast lookup in a v-table are just as possible as objects where method calls
93
+ dynamically build a call to a web service.
94
+
95
+ =head3 Portable between virtual machines
96
+ By using 6model, it should become easier to make a compiler that is portable
97
+ between VMs. Currently 6model implementations in varying states of completeness
98
+ exist on Parrot, the .Net CLR and the JVM.
99
+
100
+ =head3 Meta-objects are authoritative
101
+ In an ideal world, every single method dispatch we perform would be conducted
102
+ by delegating to the meta-object's method that implements method dispatch
103
+ semantics. In the real world, that's not practical from a performance point of
104
+ view. Thus 6model provides various mechanisms that a meta-object can "opt in"
105
+ to in order to allow for muchly increased performance. However, it considers
106
+ all of these to really just be a kind of "cache". A v-table is just an array
107
107
of invokable objects published by the meta-object, which it is responsible
108
108
for maintaining. Similar things apply to type-checking.
109
109
110
- =back
111
-
112
110
113
111
=head2 Data Structures
114
112
115
113
At the heart of 6model are three core types of data structure.
116
114
117
- =over 4
118
-
119
- =item Objects: other than native types, everything that the user ever interacts
115
+ =head3 Objects
116
+ Other than native types, everything that the user ever interacts
120
117
with directly - that is, anything that makes it into lexpads, locals, packages,
121
118
attributes and other storage locations - is an object. This is the only user-facing
122
119
data structure in 6model. An object is a blob of memory. The only constraint is
123
120
that the first thing in the blob must be a pointer/reference to a Shared Table
124
121
data structure.
125
122
126
- =item Representations: an object may in the abstract be a blob of memory that starts
123
+ =head3 Representations
124
+ An object may in the abstract be a blob of memory that starts
127
125
with a pointer to a Shared Table, but of course something has to know what the rest
128
126
of it means. That's what representations do. A representation is responsible for
129
127
object allocation, attribute storage and access (both in terms of memory layout and
@@ -135,7 +133,8 @@ that users of programming languages will (relatively) frequently engage in creat
135
133
or customizing meta-objects, the use cases for writing custom representations are
136
134
fewer.
137
135
138
- =item Shared Tables: for every object, there is a meta-object defining its
136
+ =head3 Shared Tables
137
+ For every object, there is a meta-object defining its
139
138
semantics and a representation defining its memory layout. There are also some
140
139
entities that should live outside of either of them, such as the cached v-table
141
140
that some meta-objects may publish and a reference to the type object. However,
@@ -144,10 +143,6 @@ representation). Rather than every object starting with a bunch of pointers, it
144
143
instead has one pointer to a shared table containing these things. Thus individual
145
144
objects stay small.
146
145
147
- =back
148
-
149
- So diagramatically:
150
-
151
146
+--------+ +----------------+
152
147
| Object | +-->| Shared Table |
153
148
+--------+ | +----------------+
0 commit comments