Add handling of by-name inits to commented-out class/c use in typed-scheme.

Also, fix class/c section of reference slightly by mentioning the role of
external contracts in class instantiation.

svn: r18542
This commit is contained in:
Stevie Strickland 2010-03-15 08:57:41 +00:00
parent c7c8f7061e
commit 5a488ae7cb
2 changed files with 11 additions and 8 deletions

View File

@ -1503,10 +1503,11 @@ Produces a contract for a class.
There are two major categories of contracts listed in a @scheme[class/c] There are two major categories of contracts listed in a @scheme[class/c]
form: external and internal contracts. External contracts govern behavior form: external and internal contracts. External contracts govern behavior
when methods or fields are accessed via an object of that class. Internal when an object is instantiated from a class or when methods or fields are
contracts govern behavior when method or fields are accessed within the accessed via an object of that class. Internal contracts govern behavior
class hierarchy. This separation allows for stronger contracts for class when method or fields are accessed within the class hierarchy. This
clients and weaker contracts for subclasses. separation allows for stronger contracts for class clients and weaker
contracts for subclasses.
Method contracts must contain an additional initial argument which corresponds Method contracts must contain an additional initial argument which corresponds
to the implicit @scheme[this] parameter of the method. This allows for to the implicit @scheme[this] parameter of the method. This allows for

View File

@ -151,13 +151,15 @@
[(names ...) name]) [(names ...) name])
#'(object/c (names fcn-cnts) ...))] #'(object/c (names fcn-cnts) ...))]
;; init args not currently handled by class/c ;; init args not currently handled by class/c
[(Class: _ _ (list (list name fcn) ...)) [(Class: _ (list (list by-name-init by-name-init-ty _) ...) (list (list name fcn) ...))
(when flat? (exit (fail))) (when flat? (exit (fail)))
(with-syntax ([(fcn-cnts ...) (for/list ([f fcn]) (t->c/fun f #:method #t))] (with-syntax ([(fcn-cnt ...) (for/list ([f fcn]) (t->c/fun f #:method #t))]
[(names ...) name]) [(name ...) name]
[(by-name-cnt ...) (for/list ([t by-name-init-ty]) (t->c/neg t))]
[(by-name-init ...) by-name-init])
#'class? #'class?
#; #;
#'(class/c (names fcn-cnts) ...))] #'(class/c (name fcn-cnt) ... (init [by-name-init by-name-cnt] ...)))]
[(Value: '()) #'null?] [(Value: '()) #'null?]
[(Struct: nm par flds proc poly? pred? cert acc-ids) [(Struct: nm par flds proc poly? pred? cert acc-ids)
(cond (cond