<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
I understood yesterday that Spoon doesn't send objects to be
recreated on the other side of a remote message, it sends
information about objects. It encodes objects. <br>
<br>
I see tags go over the wire and the tag types are related to classes
in the EncodingClasses classvar in MessagingSession
class>>initialize. <br>
<br>
OK, a tag called methodTag goes over the wire. Now what? <br>
It is connected in the dictionary to CompiledMethod. OK, we are
going to make an instance of a compiled method on this side from the
info coming over the wire. It's a little generic, isn't it? Don't we
need to be a little more specific about what's in it? All those byte
codes and literals? <br>
<br>
Then it occurred to me that a new instance of CM could be
populated... with the literals and material that are in a CM. What
would we do that with? The whole class category in Spoon called
LiteralMarkers. I'm guessing the markers go over the wire after the
tag. Then they get installed into the CM. Bang. You've created a CM
from a blueprint of one. <br>
<br>
That' blew my mind. CM's always seemed immutable. Seems I've just
never spent much time with CompiledMethod>>#newMethod:header:
Let's just make one with a bag of literals. <br>
<br>
And if we can make CMs from a stream of information, then we can
make anything. Classes are just collections of CMs with some
variables. <br>
<br>
Here's were we do just that: we make a CM and fill it full of
literals from literal markers. <br>
<br>
MethodEdition>>#method<br>
"Answer the method I prescribe in the local system."<br>
<br>
| method |<br>
<br>
<b>method</b> := (<br>
<b>CompiledMethod</b><br>
newMethod: (endPC - initialPC + 2)<br>
header: header).<br>
<br>
1<br>
to: literalMarkers size<br>
do: [:literalIndex |<br>
<b>method</b><br>
literalAt: literalIndex<br>
put: (literalMarkers at: literalIndex) <b>literal</b>].<br>
<br>
.. snip ...<br>
<br>
^method<br>
<br>
It seems to me these tools of tags and markers are a complete way to
describe classes and instances. They can be stored as data and then
re-instantiated on need. And I guess you could take a snapshot of
any object or set of objects to have a history or version record. <br>
<br>
Have a nice weekend, <br>
<br>
Chris <br>
</body>
</html>