smalltalk-tng

view doc/metaoperations.lyx @ 323:454c18798969

merger
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
date Tue Feb 07 11:34:20 2012 -0500 (3 months ago)
parents
children
line source
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
3 \textclass article
4 \language english
5 \inputencoding auto
6 \fontscheme default
7 \graphics default
8 \paperfontsize default
9 \spacing single
10 \papersize a4paper
11 \paperpackage widemarginsa4
12 \use_geometry 0
13 \use_amsmath 0
14 \use_natbib 0
15 \use_numerical_citations 0
16 \paperorientation portrait
17 \secnumdepth 3
18 \tocdepth 3
19 \paragraph_separation indent
20 \defskip medskip
21 \quotes_language english
22 \quotes_times 2
23 \papercolumns 1
24 \papersides 1
25 \paperpagestyle default
27 \layout Title
29 Metaoperations in ThiNG
30 \layout Author
32 Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
33 \layout Section
35 Metaprotocol
36 \layout Standard
39 \emph on
40 Q:
41 \emph default
42 What is bytecode?
43 \emph on
44 A:
45 \emph default
46 A coding for a list of messages sent to the current location.
47 \layout Standard
49 Viewing bytecode this way leads to a definition of a 3-LISP style tower-of-inter
50 preters.
51 The location is the interpreter running at phase1, interpreting code at
52 phase0.
53 The location's location is at phase2, and so on.
54 Each location runs bytecode - a sequence of messages sent to the phase
55 above.
56 \layout Standard
58 Here are the bytecode operations in use in the dummy ThiNG prototype:
59 \layout Itemize
61 local - load a value from a lexically-scoped variable
62 \layout Itemize
64 global - load a value from a per-location variable.
65 This translates to a slot access on the contents of the locations' global
66 cell, ie.
67 a unary method invocation on the globals object.
68 Adjusting the contents of the cell and updating the location with new cells
69 gives quite fine-grained thread-group-local control over global variables,
70 a.k.a.
71 ambient capabilities.
72 \layout Itemize
74 send - computes a number of values (in parallel), tuples them up with a
75 selector, and sends them through the dispatch+apply mechanism in the metaobject.
76 \layout Itemize
78 closure - takes a literal block object, cloning it with the current environment,
79 thus making a closure.
80 \layout Itemize
82 begin - performs a sequence of instructions.
83 \layout Itemize
85 scope - introduces a fresh named location, essentially starting a new sub-thread
86 -group.
87 Eventually this will be modified to allow object-code-level control over
88 the shape of the new location - within limits.
89 \layout Itemize
91 literal - loads a literal object from the code object's literal vector
92 \layout Itemize
94 update - clones an existing object, adding or updating slots according to
95 the recipe attached to the instruction.
96 \layout Itemize
98 tuple - computes a number of values in parallel, and entuples them before
99 handing the tuple back to its continuation
100 \layout Itemize
102 resend - reinvokes the dispatch mechanism, starting from the current method.
103 \layout Itemize
105 method - should be syntactic sugar for a number of reflective operations,
106 although currently is hardcoded since the necessary location-manipulation
107 isn't even implemented, let alone exposed as reflective primitives to the
108 object level.
109 \layout Standard
111 Now, with luck once the compiler gets clever enough to inline away some
112 temporary object construction, we will be able to remove tuples - the replaceme
113 nt will simply be the construction of a results object via normal update:
115 \family typewriter
116 (r1 := val1 r2 := val2 ...)
117 \family default
118 .
119 This introduces an asymmetry: function
120 \emph on
121 arguments
122 \emph default
123 will be passed using anonymous (ie.
124 indexed) tuples, but function
125 \emph on
126 results
127 \emph default
128 will be passed using named tuples.
129 \begin_inset Foot
130 collapsed false
132 \layout Standard
134 Perhaps it's worth thinking about how we might get named tuples for function
135 calls, too? One way might be to use selector fragments for positional arguments
136 , although that leaves the question of naming the leftmost argument (eg.
137 in a unary message-send).
138 It's interesting, though, because one might be able to make the argument-record
139 a step in the delegation-chain for the running frame.
140 \end_inset
143 \layout Standard
145 Execution can be viewed as a kind of fold over a sequence of operations,
146 accumulating a changed interpreter (location) state.
147 The operations folded over, then, are stack manipulations (for computing
148 arguments), delay, promise and cell operations, and:
149 \layout Itemize
152 \family typewriter
153 loc\SpecialChar ~
154 loadLocal:\SpecialChar ~
155 #
156 \emph on
157 name
158 \layout Itemize
161 \family typewriter
162 loc globals peek
163 \emph on
164 name
165 \layout Itemize
168 \family typewriter
169 loc send:\SpecialChar ~
170 #
171 \emph on
172 selector
173 \emph default
174 to:\SpecialChar ~
175 {
176 \emph on
177 arg
178 \emph default
179 .
180 \emph on
181 \SpecialChar ~
182 arg
183 \emph default
184 .\SpecialChar ~
185 ...}
186 \layout Itemize
189 \family typewriter
190 loc close:
191 \emph on
192 blocktemplate
193 \layout Itemize
196 \family typewriter
197 loc evaluate:
198 \emph on
199 bytecode
200 \emph default
201 in:
202 \emph on
203 freshlocationtemplate
204 \layout Itemize
207 \family typewriter
208 loc loadLiteral:
209 \emph on
210 literalvalue
211 \layout Itemize
214 \family typewriter
215 loc update:
216 \emph on
217 expr
218 \emph default
219 by:
220 \emph on
221 updatetemplate
222 \layout Itemize
225 \family typewriter
226 loc resend1
227 \begin_inset Quotes eld
228 \end_inset
230 avoid keyword
231 \begin_inset Quotes erd
232 \end_inset
235 \layout Section
237 Maps and Traits in functional prototype objects
238 \the_end