strong/weak typing and pointers

Diez B. Roggisch deetsNOSPAM at web.de
Tue Nov 2 10:32:34 EST 2004


> Strong typing respects data as invariant.  There is no way to "sneak
> around" a data type and "tweak" its representation.  The reason C is
> weakly typed is that you can easily get to the bits in a float (for
> example), rather than always having to deal with a float with float
> operations.

Sounds good.

> 
> Strong types provide strong protection for data types as their
> abstraction; weak types allow you to operate on data "behind the
> wall of abstraction".  A Smalltalk programmer would say that
> Python is more weakly typed than Smalltalk for user-defined types.

Never used smalltalk, so help me with understanding this:
Do you mean by that that python allows alteration of members of an object,
thus circumvening possible methods that should be used for that? Or, to put
it in an other way: do you consider the lack of a privacy policy of members
as "weak"?

If this is the case: I personally wouldn't call that "weaker" - python just
allows for more default-messages to be accepted by an object - if you want
better privacy for your members, use slots and properties. But this is of
coures not totally safe - as it is not in java c++.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list