I want to write a contract on an exported struct type that insists that
clients who derive subtypes must ensure that the fields of the parent type
are initialized with appropriate values.

The following program does the checking I want, but the blame isn't what I
want or would have expected: it blames the server module, rather than the
client, when the client tries to call the constructor for a subtype with a
bad argument.

#lang racket

(module server racket
  (provide (contract-out
            [struct base ([num number?])
  (struct base (num)

(require 'server)

(struct derived base (sym)

(derived 42 'ok)

(derived "not a number" 'bad) ;; blames server

Is this the way blame is expected to be assigned in this case? If so, is
there a way for the server to enforce the requirements I have in mind?


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to