|
Howard,
> What is doIt?
> Where is doIt?
;-)
It's not a real method, it just looks like one...
If you look down the debug stack to just below #doIt you'll see that the
workspace compiles the expression to be evaluated, creating a
CompilationResult. The compilation result contains the compiled code as its
#method (it isn't really a method, that's just the name it's given in this
context since the most important use of the compiler /is/ to create methods). .
That "method" is actually an instance of CompiledExpression (as you'll see in
the inspector). CompiledExpression and CompiledMethod are subclasses of
CompiledCode, and share a lot of similarities. If you inspect the particular
instance of CompiledExpression you'll see that its "selector" is 'doIt'.
There's no very obvious reason why a CompiledExpression has to have a selector
at all (it could be that only CompiledMethods had them); I suspect it's there
to make the debugger and/or VM simpler since they can treat "real" methods and
CompiledExpressions identically.
The "selector" itself has been generated by the compiler, and I is (as far as
I know) entirely arbitrary. You can even change it in the debugger to, say,
'some stuff evaluated in a workspace', and restart the evaluation. In that
case the debugger's stack pane will show that you are executing a "method"
called "some stuff evaluated in a workspace" ;-)
I think that some Smalltalk implementations do implement the do-it
functionality by adding a real (but temporary) method to some class or other.
I can't remember the details, I'm afraid, but it seems very much a hack to
me....
-- chris
|