[FYI] Java vs Squeak/Smalltalk

Les Tyrrell tyrrell at canis.uiuc.edu
Sun Jan 20 00:40:44 UTC 2002


----- Original Message -----
From: Ken Kahn <kenkahn at toontalk.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Saturday, January 19, 2002 4:11 PM
Subject: Re: [FYI] Java vs Squeak/Smalltalk


> Joerg Beekmann wrote:
>
> >
> > (ByteArray new: 5) at: 1 put: 8
>
> When I first glanced at your example I expected you to bring up a different
> point on this topic. Maybe I'm confused about Squeak and Smalltalk but I
> believe they come very close to allowing one to implement transparent
> forwarders but don't go all the way. Suppose the 5 in the example above was
> an instance of a user class that tries to behave like a number. It does
> arithmetic, printing, etc. just fine. Maybe all it does is forward all
> messages to a primitive 5. So can you substitute such an object for the 5 in
> the example above or does the primitive for creating ByteArrays work only if
> a built-in number follows new: ?

In this case, you will have to use a SmallInteger in the range of 0-255.

The only thing of significance here is that SmallIntegers have a structure
that is known by the VM.  But that doesn't change the fact that in this
environment, you interact with 5 in a manner which is no different from any
other object.  You can only do so by sending messages to it.  Thus, we do not
use a 5 in a manner which is in some way fundamentally different from the way
we would use any other object, and the tools we use to work with any other
object will work on a 5 as well.  Thus, it does not qualify as being some kind
of exceptional entity outside the scope of our world of objects.

And, if you are thinking that having the VM know about the structures of some
kinds of objects makes them somehow primitive, consider the fact that the VM
also has direct knowledge of the dictionaries where classes store methods, and
of the classes themselves.  But I don't think that you are ready to call those
things primitive types.  Again, we interact with them solely as objects.

Good question!

- les






More information about the Squeak-dev mailing list