strong/weak typing and pointers

Christophe Cavalaria chris.cavalaria at free.fr
Tue Nov 2 16:52:08 EST 2004


Gabriel Zachmann wrote:

>>  wall of abstraction".  A Smalltalk programmer would say that
>>  Python is more weakly typed than Smalltalk for user-defined types.
> 
> which brings me to another related question.
> 
> I understand strong/weak typing is more like a continuum --
> is there kind of a programming langauges hierarchy sorting various
> langauges accoring to "type-strongness" that is generally agreed upon?
> 
> I'd be interested in a hierarchy containing some of the following
> languages: ANSI-C++, C, Perl, Python, Pascal, ML.
> (because these happen to be some of the languages i know a bit ;-) )
> 
> Would the following be justifiable?
> 
>     Perl < C < C++ < Pascal < Python < ML ?
> 
> Or does anyone have a pointer?

If by ML you thing of OCaml you should try again. OCaml isn't type safe
because of a few modules of the standard library. The marshaling module
comes to mind. Using it you can "typecast" a pointer to an integer as a
pointer to a string and segfault in the process because the unmarshal
function trusts the caller to cast the result in the good type. In fact, it
seems impossible to write a correct typesafe marshaling module in OCaml
since there is no rtti info in the language for an anonymous piece of data.




More information about the Python-list mailing list