Everything is a distributed object
Lothar Schenk
lothar.schenk at gmx.de
Sun Oct 8 11:11:54 UTC 2006
Am Samstag, 7. Oktober 2006 21:41 schrieb Martin Drautzburg:
> As a sidenote: I have difficulties to understand how Smalltalk works,
> especially the way method calls eventually resolve to primitive calls.
Take this method in Object for example:
Object>>basicAt: index put: value
"Primitive. Assumes receiver is indexable. Store the second argument
value in the indexable element of the receiver indicated by index. Fail
if the index is not an Integer or is out of bounds. Or fail if the value is
not of the right type for this kind of collection. Answer the value that
was stored. Essential. Do not override in a subclass. See Object
documentation whatIsAPrimitive."
<primitive: 61>
index isInteger
ifTrue: [(index >= 1 and: [index <= self size])
ifTrue: [self errorImproperStore]
ifFalse: [self errorSubscriptBounds: index]].
index isNumber
ifTrue: [^self basicAt: index asInteger put: value]
ifFalse: [self errorNonIntegerIndex]
The thing in the brackets
<primitive: 61>
is a primitive call. The number 61 tells the VM which primitive to execute.
(There are also named primitives which were added later on.)
If the primitive succeeds then the method returns. If the primitive fails then
the rest of the method is executed, in this case an attempt to recover or
give a meaningful failure message.
> I'd
> be most grateful for an explanation the other way round, i.e. starting with
> the primitives and the way the entire system builds up from them.
Read
http://users.ipa.net/~dwighth/smalltalk/bluebook/bluebook_imp_toc.html
for a description of the ST80 virtual machine (the ancestor of the Squeak VM).
Regards, Lothar
More information about the Squeak-dev
mailing list
|