AW: [FYI] Java vs Squeak/Smalltalk

Andreas Raab Andreas.Raab at gmx.de
Sun Jan 20 00:30:54 UTC 2002


Ken,

> 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.

That's certainly true.

> 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: ?

It could, although right now it doesn't. It's true that the object
creation primitive through #new: expects a "primitive number" (more
accurately a primitive integer) but the failure code for this primitive
could handle this failure condition by testing for, and if needed,
asking for a primitive number. So it depends on how you look at it - the
object creation primitive cannot deal with a "non-primitive number" but
the behavior of #new: could still be well-defined for those. BTW, it
should be noted here that at some point you need to get down to
"primitive numbers" in order to do stuff like allocating the object. So
handling those non-primitive numbers in the error-recovery code seems
pretty reasonable to me.

Cheers,
  - Andreas





More information about the Squeak-dev mailing list