Who's minister of propaganda this week?

Alex Martelli aleaxit at yahoo.com
Wed Mar 14 18:09:30 EST 2001


"Steven D. Majewski" <sdm7g at virginia.edu> wrote in message
news:mailman.984595938.11127.python-list at python.org...
    [snip]
> ( OK: not having multiple dispatch in Python means that some manual
> dispatching is sometimes required, but usually this is burried deep
> in some classes __coerce__ method. )

"Usually" in arithmetic, perhaps.  For fancier stuff, lack of
multimethods sometimes cramps (not that it cramps any
less in C++, mind you), though some patterns (such as
'dynamic visitor') can help a bit in certain (reasonably
frequent) special cases.


>  If think you're expecting a file, what you are probably *really*
> expecting is a file-like object with a read or write method. Testing
> if it is in fact a file is probably the wrong thing to do. ( This
> has been termed "pedantic typechecking" in c.l.python ). If you try

Right.  But this holds in well-designed C++ as well -- one
programs (across components) via abstract interfaces (aka
pure abstract classes, aka protocol classes -- see Lakos' opus
on large-scale C++ design for a deep defense of this, as well
as the origin of the 'protocol-classes' terminology for it).

The only real issue is whether this can be checked at compile
time, or needs to be verified at runtime (in C++, you get
static checking by default, but dynamic_cast<> exists as well,
so the language explicitly recognizes the need for dynamic
typechecking of the does-this-object-implement-this-interface
variety -- it does require you to 'package' methods up into
interfaces, but that's not a big issue [the interface segregation
principle dictates that an interface must have _few_ methods;
by-method typechecks, as in Python, push that to the extreme;
and note that Martin expounded the IS principle _before_ he
became Python-interested, back when he was C++ all the
way down:-)].


Alex






More information about the Python-list mailing list