An unspeakable act

Quinn Dunkan quinn at
Wed Jul 11 20:10:30 CEST 2001

On Wed, 11 Jul 2001 08:54:11 -0700, James Logajan <JamesL at Lugoj.Com> wrote:
>Hmmm. Any language design that aspires to allow programmers the ability to
>express algorithms independent of the type of object to which it may be
>applied, such as containers, must at some level provide typeless handles. In
>C/C++ those handles are typically (void *). In Java they are typically
>Object references. In Python they are most all variables.

Not quite.  C and Java are pretty poor examples of "static typing".  Eiffel
and sather container classes use type parameters: ARRAY[INTEGER]
In haskell, most all functions are naturally polymorphic, with no declarations
required, and data constructors can take type arguments:

data Tree t = Leaf t | Node (Tree t) (Tree t)

I gather that even C++ supports something similar to eiffel generics through

When a weak type system fails, you have to cast it away, at which point you
lose all the advantages of having a type system in the first place.  I'm
surprised to hear that Java makes such common use of down casts; it seems to
make the highly deprecated C practice of throwing around void pointers into a
basic language idiom.

Eiffel has the equivalent of down casts through the assignment attempt, but
it's surrounded by blinky warning lights saying "only to implement persistence
mechanisms and other nasty tricky bits where types are lost".

I used to think of java as a sort of ugly slow version of eiffel without
contracts, but now I suppose I should add "static types" to that prejudicial
dustbin as well :)

More information about the Python-list mailing list