[Python-3000] iostack and Oh Oh

Guido van Rossum guido at python.org
Wed Dec 6 23:11:18 CET 2006

On 12/6/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> I would also like to point out again, though, that the mechanism I've
> proposed (wrapping generic functions to create interfaces) actually
> supports (or can be made to support, using appropriate convenience
> functions) all the use cases that have been put forth for interfaces,
> adaptation, and generic functions.  At least, the use cases I understand.

Would you mind going through the set example *in detail*? Or don't you
understand that use case?

> To support interface inspection in the "mapping vs. sequence", my proposed
> approach requires that you define a query operation like ismapping() or
> issequence().  This is indeed more work.  My argument, however, is that
> this is a *good* thing, because interface inspection in the general case is
> *evil*: it leads to the unfixable contextual interpretations problem,
> whenever two developers write code that inspects the same interface for
> different purposes.  So, I think it's perfectly acceptable to make people
> jump through an extra hoop in order to do that sort of thing, especially
> since it's rare that you're going to have a mapping vs. sequence type of
> problem.

Why do you think developers would abuse interfaces but they wouldn't
abuse the meaning of ismapping() or issequence()? it seems that this
doesn't help at all -- whether we call an inquiry function with a
vague meaning or we have an interface with a vague meaning,
misunderstandings are right around the corner, unless we provide as
many different query operations as there are semantic variants. And we
could solve that with "classic" interfaces just as well as with your

And the query operation doesn't help for adaptation, *unless* you go
all the way and implement essentially PyProtocols' "when <arbitrary
expression>", which I'd like to keep out of the core language and
library. I also don't like the idea that the query operation can
return a dynamic value -- it could decide whether to be a sequence or
mapping (or both) based on the time of day, or the contents of an
object, or anything else. That's more than I bargained for -- I'm only
interested in invariants that the *class* cares to provide.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list