[Types-sig] rebinding (was: const)

Greg Stein gstein@lyra.org
Thu, 30 Dec 1999 10:18:51 -0800 (PST)


On Wed, 29 Dec 1999, Paul Prescod wrote:
>...
> For now, we just need a solid definition of what types of rebinding are
> legal. There are four kinds of names:

Why not just make them all legal, and worry about this later?

>  * module -- we must always disallow rebinding these because we don't
> have a notion of two modules with the "same interface". Maybe in some
> future version we could.

Untrue. Ever look at the "anydbm" module and its cohorts? How about the
DBAPI modules?

I've said before: modules and classes both have the notion of an
interface. We ought to be able to associate an interface with a module!

>  * class -- rebinding is fine as long as the new class has a signuture
> that will produce instances that conform to the declared interface(s).
> 
> * functions and other objects -- rebinding is fine as long as the new
> function conforms to the declared interface.

These make sense.

Note on functions: how is a function declared to have a particular
signature? If the function itself is declaring the signature, then
rebinding could be allowed. For example:

interface foo:
  def bar(x: Int)->String:
    "doc string"

class baz(foo):
  def bar(x: Int)->String:
    ...

def func(x: String)->String:
  ...
def func(x: Int)->String:
  ...


In the above example, baz.bar must conform to foo.bar since the class is
supposed to conform to the foo interface.

func() is defining the module's interface, so the second func() is simply
tweaking the "final" interface.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/