Type Safety (was Re: fun and empowerment)

Les Tyrrell tyrrell at canis.uiuc.edu
Sun Jan 30 00:15:55 UTC 2000


"David N. Smith (IBM)" wrote:
>
> However, programs don't just sit there statically. Programs run. Type checking is static.
> 
> Smalltalk doesn't even have types if one uses the standard dictionary definition of type; Smalltalk has classes which are quite a different thing. But Smalltalk does not require that an instance of a specific class be passed or assigned, nor does it require an instance of one of its subclasses be used as the only alternatives.
> 
> Smalltalk allows, and programmers pass, any kind of instance which has enough of the right protocol that it won't fail. If a passed object is sent #nextPut:, #nextPutAll:, and #cr, then anything that responds to these three messages is OK to pass.
> 
> This isn't some kind of evil to be eradicated, but a true language feature unavailable in most other languages. Look around in Squeak; how often is, say, a stream passed and how often are these streams related only by their protocol?
> 
> So is this set of messages the 'type' of the parameter? It seems to me that it's these messages sent to an object in a context that matter. What do we gain by specifying them?


I'm not sure yet about what is gained, but I have been building a
system that extracts information about inter-object interfaces.

The primary objective I had was to enhance programmer understanding.
I think it has some value along those lines. Basically, its another
view of the code which has it's own properties, values, and drawbacks.
If a compiler can also make use of this information, great.  Same
goes for a testing framework, or perhaps for distributed systems that
need IDL-like information, or systems that need access to capability-like
information ( I'm not very familiar with capabilities, so perhaps not ).

One early observation: "typeless" Smalltalk quite often seems
to be remarkably well typed-  it's just that we haven't had the
mechanisms available to prove it.

I would agree with you that these things are not types, and we
should be careful in talking about them to avoid confusing them
with types.  For instance, what I'm doing would be better described
as an attempt at "interface extraction", and almost certainly is not
"type inference".


-les





More information about the Squeak-dev mailing list