<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><br></div><div><blockquote type="cite"> * If we have users write types in interfaces, what happens when<br> untyped classes try to implement those interfaces?<br></blockquote><div>Untyped interfaces can specify contracts for their methods, so could it use that?</div><br><blockquote type="cite"> * What do interface types look like? Do they list the types of methods<br> that should be in them? </blockquote><div>Based on the interface form and the Class type constructor (in v6.0.1.6), I think that they should look something like this:</div><div><font face="Courier New"> (Interface interface-type-clause ...)</font></div><div><font face="Courier New"> interface-type-clause = [method-id method-type]</font></div><div><font face="Courier New"> | #:implements interface-type</font></div><div>This is basically a simplification of the grammar for the Class type constructor, and it matches the grammar of the interface form even better than the new Class type constructor matches the grammar for the class form. </div><div><br></div><div>And it would mean that a class that uses the interface would implement the methods given, with the types given, and would also implement the interfaces given by #:implements. </div><div>So the type of this:</div><div><font face="Courier New">(require/typed “untyped.rkt” [foo<%> Foo<%>]</font></div><div><font face="Courier New">(class* object% (foo<%>)</font></div><div><font face="Courier New"> ...</font></div><div><font face="Courier New"> )</font></div><div>would have a type that includes #:implements Foo<%>, and if Foo<%> is (Interface #:implements Super-Interface<%> [m t]), then that would mean that it would include #:implements Super-Interface<%> and [m t]. The things in the Interface type could go right into the Class type. </div><div>So this:</div><div><font face="Courier New">(Class stuff ... [m1 t1] ... #:implements (Interface [m2 t2] ... #:implements (Interface [m3 t3] ...)))</font></div><div>Would mean the same as this:</div><div><font face="Courier New">(Class stuff ... [m1 t1] ... #:implements (Interface [m2 t2] ... [m3 t3] ...))</font></div><div>Which would mean the same as this:</div><div><font face="Courier New">(Class stuff ... [m1 t1] ... [m2 t2] ... [m3 t3] ...)</font></div><div><br></div><div>By the way I also noticed that class* doesn’t seem to work in typed racket either. </div><br><blockquote type="cite">Do you have a use case in mind for interface types?</blockquote><div><br></div><div>Not really anymore. </div><div>I was trying to make my own types for some of the things in racket/gui, but the new version has that already (in typed/racket/gui). </div><div>By the way it seems like typed/racket/gui is treating interface types like class types anyway, and since #:implements can be used more than once, it seems like it’s expecting that interface types should be represented with class types. </div><div><br></div><div>But still, what if I wanted to do something like this:</div><div><div>(class* object% (printable<%>)</div><div> (super-new) (inspect #f)</div><div> (: custom-print (Output-Port (U 0 1) -> Void))</div><div> (define/public (custom-print out d)</div><div> ...)</div><div> (: custom-write (Output-Port -> Void))</div><div> (define/public (custom-write out)</div><div> ...)</div><div> (: custom-display (Output-Port -> Void))</div><div> (define/public (custom-display out)</div><div> ...))</div></div><div><br></div><div>But that’s still a what if case. </div><br><blockquote type="cite">We've thought about adding something like #:implements/inits or<br>something like that for this use-case, but we haven't implemented<br>anything yet. Does that sound like it would be useful to you?<br></blockquote><div><br></div><div>Yes, it does sound useful. </div><div><br></div><div>I made a class called frame-with-callback% that inherits everything from frame% but adds callback init arguments and overrides the on-subwindow-char and on-subwindow-event methods. I can just rewrite all of the init arguments from frame%, but it would be nice to have something like #:implements/inits. </div></div><br></body></html>