some minor fiddling
svn: r8256
This commit is contained in:
parent
9e70a46c7a
commit
1d58054540
|
@ -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
|
places, this use of first-class contracts improves on Mitchell and McKim's
|
||||||
design (see comments in interfaces).
|
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
|
||||||
|
]]
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
;; --- common data definitions ------------------------------------------------
|
;; --- common data definitions ------------------------------------------------
|
||||||
|
|
||||||
#lang scheme
|
; #lang scheme
|
||||||
|
|
||||||
;; data definitions
|
;; data definitions
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#lang scheme/base
|
#lang scheme
|
||||||
|
|
||||||
(require scribble/basic
|
(require scribble/basic
|
||||||
scribble/manual)
|
(for-syntax scheme/port)
|
||||||
|
(except-in scribble/manual link))
|
||||||
|
|
||||||
(provide ctc-section
|
(provide ctc-section
|
||||||
ctc-link
|
ctc-link
|
||||||
exercise
|
exercise
|
||||||
solution)
|
solution
|
||||||
|
external-file)
|
||||||
|
|
||||||
(define (ctc-section #:tag [tag #f] . rest)
|
(define (ctc-section #:tag [tag #f] . rest)
|
||||||
(keyword-apply section
|
(keyword-apply section
|
||||||
|
@ -25,3 +28,19 @@
|
||||||
(define (solution)
|
(define (solution)
|
||||||
(bold (format "Solution to exercise ~a" exercise-number)))
|
(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)
|
Loading…
Reference in New Issue
Block a user