[Types-sig] Re: PRE-PROPOSAL: Python Interfaces

Tim Peters tim_one@email.msn.com
Wed, 25 Nov 1998 17:54:59 -0500


[TimP]
> As we discussed on the egroups version of this, if interfaces
> allow supplying impementation, then
>
>     from InterfaceSupport import deferred
>     class Stack(Interface):
>         def push(self, thing): deferred()
>         etc
>
> would make everyone who *claims* to implement Stack pick up
> the (presumably error-raising) Stack.push "deferred()"
> implementation if they don't supply their own (or inherit some
> other) real implementation of push.

[BarryW]
> That definitely does the trick, assuming we add something like
> a NotImplementedError to the core and perhaps even a builtin
> function deferred() that just raises the exception.  Half of me
> wants something a little more magical (and thus less dependent
> on the author to play> the right game)... okay make that 1/4 of
> me.. no 1/8... urg.

7/16'ths of me too, but I believe the groundrules for the Scarecrow Proposal
include "no language changes".  That leaves manual, or at best
semi-automated, convention for now.  In a Python2 world, I doubt it would be
more of an insanely protracted battle than usual <wink> to get a "defer"
keyword added, provided it worked out in practice by hand first.

Given "def push(self, thing): defer" we could peek at the bytecode today,
note the senseless LOAD_GLOBAL of "defer", and simply rewrite the user's
code for them <cackle>.

illness-runs-in-the-family-ly y'rs  - tim