some minor fiddling

svn: r8256
This commit is contained in:
Robby Findler 2008-01-08 14:58:51 +00:00
parent 9e70a46c7a
commit 1d58054540
3 changed files with 43 additions and 4 deletions

View File

@ -63,3 +63,23 @@ Note: To mimic Mitchell and McKim's informal notion of parametericity
places, this use of first-class contracts improves on Mitchell and McKim's
design (see comments in interfaces).
@; @external-file[1]
@section{A Customer Manager Component for Managing Customer Relationships}
@begin[
#reader scribble/comment-reader
[schememod
scheme
;; data definitions
(define id? symbol?)
(define id-equal? eq?)
(define-struct basic-customer (id name address) #:mutable)
;; interface
(provide/contract
[id? (-> any/c boolean?)]
[id-equal? (-> id? id? boolean?)]
[struct basic-customer ((id id?) (name string?) (address string?))])
;; end of interface
]]

View File

@ -2,7 +2,7 @@
;; --- common data definitions ------------------------------------------------
#lang scheme
; #lang scheme
;; data definitions

View File

@ -1,11 +1,14 @@
#lang scheme/base
#lang scheme
(require scribble/basic
scribble/manual)
(for-syntax scheme/port)
(except-in scribble/manual link))
(provide ctc-section
ctc-link
exercise
solution)
solution
external-file)
(define (ctc-section #:tag [tag #f] . rest)
(keyword-apply section
@ -25,3 +28,19 @@
(define (solution)
(bold (format "Solution to exercise ~a" exercise-number)))
(define-syntax (external-file stx)
(syntax-case stx ()
[(_ filename)
(call-with-input-file (build-path "contracts-examples" (format "~a.ss" (syntax-e #'filename)))
(λ (port)
(define prefix "#reader scribble/comment-reader\n[schememod\nscheme\n")
(define suffix "]")
(with-syntax ([s (parameterize ([read-accept-reader #t])
(read-syntax 'contract-examples
(input-port-append #f
(open-input-string prefix)
port
(open-input-string suffix))))])
#'s)))]))
;(external-file 1)