Summary: strong/weak typing and pointers
Diez B. Roggisch
deetsNOSPAM at web.de
Thu Nov 4 07:25:26 EST 2004
> A case could be made that this "problem" isn't really valid if you look
> at "implicit coercions" in the right way.
>
> I'd argue that a programmer-overloaded operation providing coercion is
> not _implicit_ in the same sense that language-default coercion is.
> Admittedly, the coercion may not be immediately evident at the point of
> use, but one can still find the explicitly-coercing code somewhere
> inside the application (and/or included libraries). In contrast, the
> coercions that happen in Perl, PHP, etc., are not explicitly stated
> *anywhere* in the application. The difference between these two
> scenarios is, at least in my mind, very distinct and (at least as far as
> language philosophy) very profound -- it's one of *permitting*
> semi-implicit coercions (if the programmer *really* wants them) versus
> one of *mandating* implicit coercions whether the programmer wants them
> or not.
I'd second that - writing apus in php can lead to great surprises of what
actually happens - take this for example:
$foo = "abc";
$foo[0] = 65;
The result is
"6bc"
I have no idea what php actually _does_ here- perform a string conversion on
65, then taking the most signficant digit? There's all sorts of stuff like
that in php.
So while overloading allows for deliberate (and thus hopefully well-defined
or at least more or less understood) coercions, built-in doesen't.
And don't forget: If you don't like the way someone overloaded some
operator, you can alter that behaviour according to your own design
philosophies.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list