[Python-3000] Abilities / Interfaces
Guido van Rossum
guido at python.org
Thu Nov 23 00:44:23 CET 2006
Touche.
I think what I was trying to argue is that I probably wouldn't have
written it using function overloading, but I would have liked to write
the if-test using has_ability(to_addrs, String) instead of
isinstance(to_addrs, basestring). (The fact that I even wrote
basestring suggests that I was feeling a *little* guilty about the
isinstance() call. :-)
I also believe that a has_ability() test applies to places where
function overloading doesn't, e.g. when the object that could be one
of two kinds is not directly an argument but retrieved from a
container or returned by some function. Having to introduce an
overloaded helper just to avoid a single has_ability() call is a lot
of distraction.
On 11/22/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 03:19 PM 11/22/2006 -0800, Guido van Rossum wrote:
> >I consider it a waste of time since the if-version works and there's
> >no reason for it to be extensible.
>
> But if that's true, then there's no reason for it to use interfaces,
> either, is there? :) It seems like a double standard to say, "well,
> sometimes you have quick-and-dirty code that doesn't need extensibility",
> and then later complain that it should be able to check for an interface,
> instead of using either a concrete type or an overload or generic.
>
> That is, I don't think you can use the quick'n'dirty case simultaneously as
> an argument against overloads and *for* interfaces. :)
>
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list