type checking

Matej Košík kosik at fiit.stuba.sk
Mon Sep 5 17:07:47 UTC 2005


Kalecser Kurtz wrote:
> In smalltalk's dynamic typing aproach, do you think it's a good practice 
> to throw errors when the user try to use incompatible types?
> 
> For example:
> 
> - I create a class 'Mock' to mock general objects;
> - I create a class 'EntityMock' that is a Mock, but just to mock 
> Entities, once entities use doesNotUnderstand to resolve some of it's 
> methods;
> 
> So, if the user create a EntityMock with any other object than an entity 
> should the system warn him?

Hello

It really depends on the situation. There is no definitive answer to 
your question. Eitherway, I think that one can get used to the fact 
there is neiter explicit compile-time nor explicit run-time type 
checking. Do not be afraid. I haven't seen anyone doing such things.

In my code I usually drop few words in a comment about types of the 
parameters and their meaning. I am commenting the code for me.

Smalltalk is not typed. That has drawback (certain kinds of bugs are 
revealed at compile time (usually) rather than in compile time). There 
is no easy way how to do formal (Smalltalk) code verification with 
respect to formal specification (I have not seen any documents dealing 
with this problem in Smalltalk. But I personally do not miss the 
possiblility to be able to work with formal specification and to refine 
it to Smalltalk code. The reasonable thing that could be valuable, would 
be to make the language as close to the "formal specification" as 
possible, so that we could regard the actual code as executable 
specification. Indeed, there are many problems, which couldn't be 
specified first and then implemented, because you cannot formalize 
properties like "beauty", "easiness to use", "comprehensiveness of the 
generated drawing of graph", "correctness of the face recognition". So I 
do not miss this possibility).

(I admit that other people could have different opinions. Things are fuzzy)

Doing Smalltalk programming is little bit like jumping over the cliff 
with a parachute. The result either works---or not.
-- 
Matej Košík



More information about the Squeak-dev mailing list