[Python-3000] Builtin iterator type
Jan Grant
jan.grant at bristol.ac.uk
Sun Nov 19 12:57:38 CET 2006
On Sat, 18 Nov 2006, Neil Toronto wrote:
> Guido van Rossum wrote:
> > I realize that Java- and Zope-style interfaces *seem* to be all about
> > syntax (they define names and signatures of methods but not semantics)
> > but IMO that's only a theoretical objection; in *practice* these
> > interfaces have strong connotations of semantics (albeit written in
> > Enlish rather than using assertions or pre- and post-conditions) and
> > nobody would think of claiming to implement an interface without
> > implementing the proper semantics (or some interpretation thereof :-)
>
> Actually, plenty of people would dream of it and even do it. I've seen
> some pretty evil implementations of Java interfaces. All they can
> enforce is static types and method signatures.
This seems to be an argument that interfaces can be misused by people
without taste. That's true; but the same arguments have been levelled
against pretty much all language features (operator overloading,
asepct-orientation, etc).
It strikes me that one aspect of "being Pythonic" is a strong reliance
on politeness: that's what duck-typing is all about. Or conventions for
private attributes. Such features could potentially be abused, but a
Python programmer has the good taste to know what's abuse and what
isn't.
> My main point is, unless you're willing to go whole-hog with pre- and
> post-conditions (and even that would be insufficient, as you can't check
> anything like "this eventually, on some call, responds with x" without
> spelling it out in temporal logic and running model checking software),
> no interface can enforce anything *semantically* meaningful. The most
> useful thing an interface can do is *communicate* semantics to another
> programmer.
Interfaces are more than just language constructs. They come with a
semantics. It's true that that semantics may be spelled out in javadoc,
but since the consumer of the interface is another programmer, that's
ok: we want to communicate effectively to that programmer the contract
that they are agreeing to uphold when they implement that interface.
It's true that lots of Java programmers may not quite grok this from the
word go; but fundamentally an interface should be viewed as a type (or
ability marker, as Andrew K called it) and comes with a corresponding
set of semantics. That Java doesn't make an attempt to spell out
explicitly in code those other semantics isn't necessarily a weakness.
Java interfaces are very useful, however. Java programming seems to be
less and less about inheritance and more and more about implementing
interfaces; at least it does amongst Java programmers with taste :-)
Cheers,
jan
--
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661 http://ioctl.org/jan/
Whenever I see a dog salivate I get an insatiable urge to ring a bell.
More information about the Python-3000
mailing list