[racket] typed racket and interfaces

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Thu May 1 23:49:40 EDT 2014

On 2014-05-01 22:53:49 -0400, Alexander D. Knauth wrote:
> Is there a type constructor for interfaces?  And if there is, would
> (Instance Interface<%>) work (like (is-a?/c interface<%>) works)?

There is not (yet) and I don't know how we will support it if we do.
Right now the only option is to remove interfaces from your code and use
types instead to enforce that methods are implemented.

There are some design choices that aren't really obvious (at least to
me) with interfaces.

  * If we have users write types in interfaces, what happens when
    untyped classes try to implement those interfaces?

  * What do interface types look like? Do they list the types of methods
    that should be in them? But then what does it mean to have

      (require/typed "untyped.rkt" [foo<%> (Interface [m ...])])

    in your program?

and so on. Also, I'm not sure interfaces add all that much value when
you have a structural type system like TR does.

Do you have a use case in mind for interface types?

> Is there a way to specify inheritance in a class or interface type
> constructor (so then you can avoid some copying and pasting)?

IIUC, your question is basically "why does #:implements in Class types
not copy over initialization arguments?".

If that's the right interpretation, the answer is that in general
subclasses don't inherit all of the init arguments (if they use
`super-new` with arguments) so we made the default to not copy them.

We've thought about adding something like #:implements/inits or
something like that for this use-case, but we haven't implemented
anything yet. Does that sound like it would be useful to you?

Cheers,
Asumu

Posted on the users mailing list.