strong/weak typing and pointers

Diez B. Roggisch deetsNOSPAM at
Tue Nov 2 20:33:09 CET 2004

> So you would say that in PHP the + operator cannot be viewed as overloaded
> with
> the signature (string, int) -> string?  I don't know PHP, so could you
> maybe you could give an example of why you think this is so?

If you do this:

"a" + 10

you end with 10 - if the string doesn't contain something as number
interpretable, the coercion results in null.

Sure, that behaviour can be seen as overloaded, too. But overloaded
functions usually make some sort of sense, where this technique masks
errors by _always_ trying to interpret values as useful to every operation.

>> The question remains if permanent coercions as php (and afaik perl) do
>> can also be considered weak typing, as you won't end up with an error for
>> more or less anything you do.
> Sorry, I don't know what "permanent coercions" means.  Could you explain?
> "Permanent coercions" makes me expect something like:

I'm no native speaker, so I maybe confused the meaning of permanent. In
german, permanent not only means that things are enduring, but also that
things are done on regular bases: "He permanently changed his cloth." 

What I wanted to say is that php uses coercions or overloaded operators for
nearly everything. Sometimes this is totally silent, sometimes nothing
happens and a warning is issued - which might be configured to be treated
as an actual error, I'm not sure about that.

So while there migth be in fact type information present, it's rarely used -
which I consider as beeing weak.

Does that make more sense?


Diez B. Roggisch

More information about the Python-list mailing list