Newsgroups: comp.object,comp.lang.smalltalk,comp.lang.c++,comp.lang.misc
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.kei.com!simtel!lll-winken.llnl.gov!uwm.edu!vixen.cso.uiuc.edu!sdd.hp.com!hplabs!hplextra!hplb!cdollin!kers
From: kers@hplb.hpl.hp.com (Chris Dollin)
Subject: Re: Types, types: static vs. dynamic -- classification
Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
Message-ID: <KERS.95Nov21084420@cdollin.hpl.hp.com>
In-Reply-To: mklein@alumni.caltech.edu's message of 20 Nov 1995 12:04:32 GMT
Date: Tue, 21 Nov 1995 15:44:20 GMT
References: <vwjviowz091.fsf@osfb.aber.ac.uk> <vwju44dzlwt.fsf@osfb.aber.ac.uk>
	<KERS.95Nov17135258@cdollin.hpl.hp.com> <48iv37$l4c@plato.ansa.co.uk>
	<48pqsg$7mb@gap.cco.caltech.edu>
Nntp-Posting-Host: cdollin.hpl.hp.com
Organization: Hewlett-Packard Laboratories, Bristol, UK.
Lines: 81
Xref: glinda.oz.cs.cmu.edu comp.object:41050 comp.lang.smalltalk:30877 comp.lang.c++:161118 comp.lang.misc:23928

mklein@alumni.caltech.edu (Michael S. Klein) writes:

   Consider adding the following method to Integer:

   foo
       self isEven ifTrue: [
	   ^self doesNotUnderstand: (Message selector: #foo arguments: #() )
       ].
       ^self

   There.  Now even numbers are a different type than odd numbers.

If one takes the sending of doesNotUnderstand to signify type errors, then
yes, that's true. Indeed the even numbers *are* of a different type from the 
odd ones, as can easily be seen; the even numbers are guaranteed to be
divisible by two, and the odd numbers are guaranteed *not* to be so divisible,
so they have different behaviour when division-by-two-leaving-no-remainder
is part of the operation set.

   Here's an other to consider: (for Symbol)

   bar: luckyRecipient
      ^luckyRecipient perform: self

   Now just what is the type of luckyRecipient?

Can't tell without seeing the rest of the system; nothing new there. What's
the type of input.tokenise.parse.conflate?

   Are positive numbers different types than negatives.  

Yes, given ...

   Negatives dont understand the sqrt message in any meaningful way.

[Did someone forget to implement complex arithmetic?]

   All objects can be sent *any* message.  doesNotUnderstand is sent by the 
   VM when no implementation is found.  Sometimes this is an indication of a 
   'type' error. Sometimes it is an indication of forgetting to implement a 
   method.  Sometimes it is used for some sort of dynamic dispatching
   mechanism.

Yes; you need to decide what you want the instances of dNU to mean.

   I have not yet seen any definition of type that works meaningfully with 
   Smalltalk, let alone an implementation of types in Smalltalk.

So what were the propblems you found with type = operations + arguments +
results + effects?

   I do not have an a-priori concept of type.  Rather, I accept that 
   Smalltalk does not have types because types are not defined in Smalltalk.

Types are not part of Smalltalk the *language*, true; that doesn't stop
them being a useful way to organise ones thinking.

   Two non-identical objects will behave non-identically.  The idea of a
   set of uniformly behaving objects (other than sets containing all objects, and
   sets containing one object) is a fantasy.  It makes sense intuitively, and
   we can use the idea loosely, but not strictly. 

Why can't we use the idea strictly?

   Strictly speaking, there is no way of meaningfully saying that two 
   different objects will behave the same.

I don't see that; you specify the operations, you specify their meaning,
and you say that both objects satisfy those specifications; that's what you
*mean* by saying ``behave the same''.

   Yes, other languages do have types.  Smalltalk is different.  Classes are an
   implementation for objects behavior, not a way of indicating that objects of
   that class will all behave the same.

No-one (well, in any case certainly not I) is arguing that Smalltalk's classes
are its types.
--

Regards,    | ``"I can't suit myself," said Weinbaum, a little petulantly.
Kers.       | "I work for the Government".'' - Blish, "The Quincunx of Time".
