Inefficiency of __getattr__

Kragen Sitaker kragen at dnaco.net
Wed Oct 4 01:41:01 EDT 2000


In article <mailman.970553407.740.python-list at python.org>,
 <jay.krell at cornell.edu> wrote:
>>Every time I've argued static versus dynamic typing with a
>>static-typing fan, they've ended up concluding that what they really
>>hate is not dynamic typing but silent coercions.
>
>You haven't argued with me. :)
>C++ allows silent coercions in a few places that make sense -- cast to base
>class, call of user defined "operator T()" and call of user defined
>constructor, besides the "usual" numeric conversions and conversion of 0 to
>any pointer type (this can actually be a problem, like where stuff is
>defined to operate on integers and pointers, the language would be much
>better off with magic like
>#define NULL __null
>than #define NULL 0 where "_null" is compiler magic for the null pointer of
>any type and 0 favors being an integer before being a pointer..
>std::vector<int>'s constructor runs into this problem).
>
>To keep things from a exploding combinatorially in the compiler, the
>language only allows one level of silent conversion.

OK, so you agree that silent coercions cause problems in some cases in
C++, some of which cases are built into the language.

So what's the advantage of static typing over dynamic typing?  Does it
help you catch bugs, and if so, which ones?
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]





More information about the Python-list mailing list