types (was: ARGON)
Alaric B. Williams
alaric@abwillms.demon.co.uk
Tue, 31 Dec 1996 18:07:39 +0000
On 30 Dec 96 at 1:55, Jecel Assumpcao Jr wrote:
> Sorry this is so late, but I hope it will help you think
> about this.
> Smalltalk-80 originally used 15 bit integers for most
> math, then moved to 31 bits on the Vax (though 30 bits
> are more common now). No programs had to be rewritten
> and nothing broke in all these changes. Isn't this the
> kind of thing we want?
Yup! I detest the concept of an "integer" type, in general. You can't
tell if it's two bits long or a thousand bits... my way around this
is parametric integers:
[U|S][1..n]
eg:
U8 (unsigned eight bits)
S35 (signed 35 bits)
The benefit: The programmer knows exactly what he's getting, and the
compiler knows exactly what the programmer wants. The downfall: many
bit widths have to be emulated in software, slowing things down.
> Leaving out abstract types leads us to the infamous
> "message not understood" problems of Self and Smalltalk.
> But mixing up the kinds of types and putting concrete
> types (COBOL pictures) in the language definition makes
> the programmer do the compiler's job. I advise against
> it.
A useful way of looking at all this is to think of seperate
inheritance of behaviour and interface. C++ inheritance is what we
would call behaviour inheritance; interface inheritance purely
controls abstract class membership. In C++ as it is, when you inherit
an interface, you can't help but inherit the implementation! These
new "signature" thingummies may be a solution, though... they are
used as the type specifiers in parameters, and they basically say
"Any object of a class which implements this interface".
ABW
--
Governments are merely protection rackets with good images.
Alaric B. Williams Internet : alaric@abwillms.demon.co.uk
http://www.abwillms.demon.co.uk/