On Wed, 22 Nov 2006, Guido van Rossum wrote:

> On 11/22/06, Andrew Koenig <[EMAIL PROTECTED]> wrote:
> > > Hm, I would think it extends very naturally to instance variables, and
> > > I see no reason why it's a particularly bad idea to also extend it
> > > (mostly in our minds anyway, I expect) to describe certain behaviors
> > > that cannot be expressed (easily) in code.
> >
> > I think of an ability as a property of an interface rather than an interface
> > itself.  For example, I can imagine a single interface having multiple
> > abilities.
> 
> Hm, that sounds like a case for inheritance. The abilities would be
> the bases and the interface would extend all of them. They could all
> be called abilities or they could all be called interfaces. The
> linguistic metaphor only goes so far...

I don't think it's quite inheritance (except in the set-theoretic 
sense), unless you can define new superclasses to existing interfaces.

To illustrate, let's say that python can take "typed" arguments. You 
write a function, foo, that has one argument. That argument must have 
two separate abilities: let's say (for argument's sake) that we want to 
iterate over its contents (bad choice, perhaps, but bear with me) and 
also persist it. How do we declare the function?

        interface interable_and_serialisable(iterable, serialisable):
                pass

        def foo(x : iterable_and_serialisable):
                etc.

That's great, but if we want to call foo(x) for an x that comes from a 
third-party library? Perhaps the library owner even was kind enough to 
declare that x implemented "iterable" and "serialisable". We've invented 
"iterable_and_serialisable" after the library was written. Unless we can 
go back and declare that the class of x implements that interface, 
there's an impasse. Fine-grained "abilities" lead to some kind of simple 
ability algebra or other hoop-jumping if you want to do typing of 
arguments.

Of course, without typed arguments we can simply check that x implements 
iterable and serialisable inside the body of "foo".

(Perhaps this is a non-problem: it certainly doesn't appear to crop up 
much in the Java world.)

jan

-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
Hang on, wasn't he holding a wooden parrot? No! It was a porcelain owl.
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to