strong/weak typing and pointers

Diez B. Roggisch deets.nospaaam at web.de
Tue Nov 2 07:29:44 EST 2004


>>  It seems that you mistake strong/weak typing with static/dynamic typing
>>  - a
> 
> sorry, i don't think so.

I still do - as your other post regarding dynamic aspects of printf makes me
think so. 

Dynamic typing means that at runtime, type-information is associated with 
data and used e.g. to determine what implementation for certain operations
is to be taking. Static typing means that type information is used during
compiletime. Python is purely dynamic, java has both aspects and C++ is
mainly static - albeit rtti (and virtual methods somehow) are dynamic. So
one could say its mixed.

Strong/weak typing is about how much you care of types at all - in php, its
perfectly legal to add strings to numbers - the string simply gets
converted to a number beforehand, that conversion yielding 0 when there is
nothing useful and numberlike can be extracted from the string. So typing
is weak, as it doesn't constrain the possible operations on variables with
certain values.


> haven't tried that yet, but i guess it would at least evoke a warning in
> ANSI C++.

No, as others pointed out its a legal pointer operation

> i am just trying to come up with the best possible definition of "weak and
> strong typing" ( "best" in the sense of completeness and objectiveness).
> I've read up quite a bit about strong/weak typing, and static and dynamic
> typing, and it seems to me that, while static/dynamic typing is a pretty
> well-defined concept, the definition of strong/weak typing is not so
> clear-cut.

That might be - but you put python and c++ in the same sentence as weak and
strong typing - and that looked as if you think of python beeing weakly
typed, which it is not.


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list