[racket] Contracts in interfaces

From: Gregory Woodhouse (gregwoodhouse at me.com)
Date: Tue Sep 25 01:00:29 EDT 2012

In writing contracts for classes I always use the ->m constructor for methods, so this example of section 5.1 of the Reference surprises me

(define file-interface<%>
  (interface () open close read-byte write-byte))

(define directory-interface<%>
  (interface (file-interface<%>)
    [file-list (-> (listof (is-a?/c file-interface<%>)))]

It looks like -> contract constructor means the same thing except, of course, the context is an interface definition and a class contract, so it's clear from context that this a method and not a function.

Second question: Is the inclusion of contracts in interface definitions a new feature? I've always written interfaces using only method names and have missed the ability to specify the shape of the method (something more analogous to what a Java interface does). It's entirely possible that this has been in the Reference a long time and I just missed it. In fact, I'm continually amazed at how much is there that I've missed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120924/9118de4a/attachment-0001.html>

Posted on the users mailing list.