strong/weak typing and pointers

Gabriel Zachmann zach at cs.uni-bonn.de
Tue Nov 2 04:50:04 EST 2004


>  It seems that you mistake strong/weak typing with static/dynamic typing - a

sorry, i don't think so.

>  completely different beast.
>  
>  Python is in fact strong typed - in opposition to php or perl or even C,
>  this won't work:
>  
>  a = "1" + 2

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

>  as "1" is a string and 2 an integer. And even though C is statically typed,

In C++, "1" is a 'char const * const'.

>  it won't complain - you just end up with an unexpected result.
>  
>  And pointers are not evil in themselves - the are a neccessity to create

i didn't say that.
In fact, they are everywhere, even in Python and Java, except that you
don't get to see them.

>  recursive structures. But deliberately casting pointers can be very harmful 

i agree.

>  - a reason why its forbidden in languages like java and AFAIK ada.
>  
>  > More concretely, I am thinking particularly of Python vs C++.
>  > So, are there any examples (without pointers, references, or
>  > adress-taking), which would have a different result in Python and in C++?
>  
>  I have difficulties to understand what you want here. Please elaborate.

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.

Cheers,
Gab.

-- 
/-------------------------------------------------------------------------\
| There are works which wait,                                             |
| and which one does not understand for a long time; [...]                |
| for the question often arrives a terribly long time after the answer.   |
|                                                         (Oscar Wilde)   |
+-------------------------------------------------------------------------+
| zach at cs.uni-bonn.de            __@/'        www.gabrielzachmann.org     |
\-------------------------------------------------------------------------/



More information about the Python-list mailing list