Missing interfaces in Python...

Alex Martelli aleaxit at yahoo.com
Mon Apr 17 22:14:19 EDT 2006


Jonathan Daugherty <cygnus at cprogrammer.org> wrote:

> # enforced by whom, at what point ?
> 
> In the case of Java, I think the JVM enforces interface implementation
> (probably at the parser level).

"parser"...?!  If you have an 'Object o', say one just received as an
argument, and cast it to IBlahble, a la

    IBlahble blah = (IBlahble) o;

...what can the parser ever say about it?  It's clearly up to the
runtime system to "enforce" whatever -- raising the appropriate
exception if the "actual" (leafmost) class of o does not in fact
implement IBlahble (Java doesn't _really_ do compile-time static typing:
it just forces you to violate the "Don't Repeat Yourself" cardinal rule
by redundantly repeating types, as above, but then in general it checks
things at runtime anyway!).


Alex



More information about the Python-list mailing list