strong/weak typing and pointers
Steven Bethard
steven.bethard at gmail.com
Tue Nov 2 20:11:17 EST 2004
More information about the Python-list mailing list
Tue Nov 2 20:11:17 EST 2004
- Previous message (by thread): strong/weak typing and pointers
- Next message (by thread): strong/weak typing and pointers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christophe Cavalaria <chris.cavalaria <at> free.fr> writes: > > > Note that PHP doesn't fit your definition above anyway. When PHP allows: > > > > "a" + 10 == 10 > > > > it's not incorrectly using "some piece of data by applying to it the wrong > > type". It's doing exactly what it tells you it'll do. This is *correct* > > response given the PHP language definition. > > Incorrectly is a view of the mind in that case. From my point of view it is > incorrect. And you could argue that taking a float * and casting it into a > int * gives us a predictable behaviour. It'll still be wrong to do it > unless it was exactly what you wanted to do. And in that case you can > create explicit language constructs to do the trick. The problem is, "exactly what you wanted to do" varies from programmer to programmer. Some programmers may actually want "a" + 10 == 10. I can imagine code that takes a string as input and adds its integer value to an int counter. Invalid input should not increment the counter and may be silently ignored. I would not write code this way, but some people would, and would want the code to work the way PHP does. So yes, "incorrectly is a view of the mind", but since we can't know what every programmer is thinking, and it's extremely unlikely that every programmer will agree what's correct or incorrect for every example, so we have to take the language definition as the measuring stick for correct or incorrect. Given that, your definition of weakly-typed: "A weakly typed language is a language that often uses incorectly some piece of data by applying to it the wrong type" either would not call PHP a weakly-typed language, because the data is not used incorrectly according to the language definition, or would not know what to call PHP, because incorrectly cannot be defined in a way that applies correctly to all programmers. I prefer not extending "weakly-typed" in this way because it makes the term less well-defined. Steve
- Previous message (by thread): strong/weak typing and pointers
- Next message (by thread): strong/weak typing and pointers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list