diff --git a/collects/macro-debugger/model/context.ss b/collects/macro-debugger/model/context.ss index 7ed83c0f96..c385afff38 100644 --- a/collects/macro-debugger/model/context.ss +++ b/collects/macro-debugger/model/context.ss @@ -6,8 +6,7 @@ path-get pathseg-get path-replace - pathseg-replace - find-subterm-paths) + pathseg-replace) ;; A Path is a (list-of PathSeg) ;; where the PathSegs are listed outermost to innermost @@ -117,25 +116,3 @@ (define (sd x) (syntax->datum (datum->syntax #f x))) - -;;======= - -;; find-subterm-paths : syntax syntax -> (list-of Path) -(define (find-subterm-paths subterm term) - (let outer-loop ([term term]) - (cond [(eq? subterm term) - (list null)] - [(stx-pair? term) - ;; Optimized for lists... - (let loop ([term term] [n 0]) - (if (stx-pair? term) - (let* ([seg0 (make-ref n)]) - (append (map (lambda (p) (cons seg0 p)) (outer-loop (stx-car term))) - (if (eq? subterm (stx-cdr term)) - (list (list (make-tail n))) - (loop (stx-cdr term) (add1 n))))) - (let ([seg0 (make-tail n)]) - (map (lambda (p) (cons seg0 p)) - (outer-loop term)))))] - ;; FIXME: more structured cases here: box, vector, ... - [else null]))) diff --git a/collects/macro-debugger/model/synth-config.ss b/collects/macro-debugger/model/synth-config.ss deleted file mode 100644 index 2c42314301..0000000000 --- a/collects/macro-debugger/model/synth-config.ss +++ /dev/null @@ -1,111 +0,0 @@ -#lang scheme/base -(require (for-syntax scheme/base) - scheme/match - scheme/contract - "deriv.ss" - "deriv-util.ss" - "reductions-config.ss" - "stx-util.ss") - -(provide current-unvisited-lifts - current-unhidden-lifts - - current-hiding-warning-handler - - handle-hiding-failure - warn - - DEBUG-LIFTS - - add-unhidden-lift - extract/remove-unvisited-lift) - -;; Parameters - -;; current-hiding-warning-handler : (parameter-of (symbol any -> void)) -(define current-hiding-warning-handler - (make-parameter - (lambda (tag args) (printf "hiding warning: ~a\n" tag)))) - -;; current-unvisited-lifts : (paramter-of Derivation) -;; The derivs for the lifts yet to be seen in the processing -;; of the first part of the current lift-deriv. -(define current-unvisited-lifts (make-parameter null)) - -;; current-unhidden-lifts : (parameter-of Derivation) -;; The derivs for those lifts that occur within unhidden macros. -;; Derivs are moved from the current-unvisited-lifts to this list. -(define current-unhidden-lifts (make-parameter null)) - -;; Helper - -(define-syntax DEBUG-LIFTS - (syntax-rules () - [(DEBUG-LIFTS . b) - (void)] - #; - [(DEBUG-LIFTS . b) - (begin . b)])) - -;; Operations - -;; add-unhidden-lift : Derivation -> void -(define (add-unhidden-lift d) - (when d - (current-unhidden-lifts - (cons d (current-unhidden-lifts))))) - -;; extract/remove-unvisted-lift : identifier -> Derivation -(define (extract/remove-unvisited-lift id) - (define (get-defined-id d) - (match d - [(Wrap deriv (e1 e2)) - (with-syntax ([(?define-values (?id) ?expr) e1]) - #'?id)])) - ;; The Wrong Way - (let ([unvisited (current-unvisited-lifts)]) - (if (null? unvisited) - (begin (DEBUG-LIFTS - (printf "hide:extract/remove-unvisited-lift: out of lifts!")) - #f) - (let ([lift (car unvisited)]) - (DEBUG-LIFTS - (printf "extracting lift: ~s left\n" (length (cdr unvisited)))) - (current-unvisited-lifts (cdr unvisited)) - lift))) - ;; The Right Way - ;; FIXME: Doesn't work inside of modules. Why not? - #; - (let loop ([lifts (current-unvisited-lifts)] - [prefix null]) - (cond [(null? lifts) - (DEBUG-LIFTS - (fprintf (current-error-port) - "hide:extract/remove-unvisited-lift: can't find lift for ~s~n" - id)) - (raise (make localactions))] - [(bound-identifier=? id (get-defined-id (car lifts))) - (let ([lift (car lifts)]) - (current-unvisited-lifts - (let loop ([prefix prefix] [lifts (cdr lifts)]) - (if (null? prefix) - lifts - (loop (cdr prefix) (cons (car prefix) lifts))))) - lift)] - [else - (loop (cdr lifts) (cons (car lifts) prefix))]))) - -;; Warnings - -(define (warn tag . args) - ((current-hiding-warning-handler) tag args)) - -(define (handle-hiding-failure d failure) - (match failure - [(struct nonlinearity (term paths)) - (warn 'nonlinearity term paths d)] - [(struct localactions ()) - (warn 'localactions d)] - [(struct hidden-lift-site ()) - (warn 'hidden-lift-site d)])) - diff --git a/collects/macro-debugger/syntax-browser/controller.ss b/collects/macro-debugger/syntax-browser/controller.ss index 030c9389d1..e1a1da87e5 100644 --- a/collects/macro-debugger/syntax-browser/controller.ss +++ b/collects/macro-debugger/syntax-browser/controller.ss @@ -1,10 +1,11 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:] + [init-field/i init-field:]) "interfaces.ss" "partition.ss" - "../util/notify.ss") + unstable/gui/notify) (provide controller%) ;; displays-manager-mixin diff --git a/collects/macro-debugger/syntax-browser/display.ss b/collects/macro-debugger/syntax-browser/display.ss index 9fe40f88ca..2de3c18e93 100644 --- a/collects/macro-debugger/syntax-browser/display.ss +++ b/collects/macro-debugger/syntax-browser/display.ss @@ -2,7 +2,9 @@ (require scheme/class scheme/gui scheme/list - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:] + [init-field/i init-field:]) (only-in mzlib/etc begin-with-definitions) "pretty-printer.ss" "interfaces.ss" diff --git a/collects/macro-debugger/syntax-browser/frame.ss b/collects/macro-debugger/syntax-browser/frame.ss index 9f41e052c3..7b4a3fffcf 100644 --- a/collects/macro-debugger/syntax-browser/frame.ss +++ b/collects/macro-debugger/syntax-browser/frame.ss @@ -1,6 +1,10 @@ #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [define/i define:] + [send/i send:] + [send*/i send*:] + [init-field/i init-field:]) scheme/gui framework/framework scheme/list diff --git a/collects/macro-debugger/syntax-browser/interfaces.ss b/collects/macro-debugger/syntax-browser/interfaces.ss index 4f71cb542e..5b72ce7eb5 100644 --- a/collects/macro-debugger/syntax-browser/interfaces.ss +++ b/collects/macro-debugger/syntax-browser/interfaces.ss @@ -1,6 +1,6 @@ #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + unstable/class-iop (for-syntax scheme/base)) (provide (all-defined-out)) diff --git a/collects/macro-debugger/syntax-browser/keymap.ss b/collects/macro-debugger/syntax-browser/keymap.ss index 7bc7c8fd17..10dad67c8f 100644 --- a/collects/macro-debugger/syntax-browser/keymap.ss +++ b/collects/macro-debugger/syntax-browser/keymap.ss @@ -1,7 +1,7 @@ #lang scheme/base (require scheme/class scheme/gui - "../util/notify.ss" + unstable/gui/notify "interfaces.ss" "partition.ss") (provide smart-keymap% diff --git a/collects/macro-debugger/syntax-browser/prefs.ss b/collects/macro-debugger/syntax-browser/prefs.ss index fe86c83f47..ca3d7723c7 100644 --- a/collects/macro-debugger/syntax-browser/prefs.ss +++ b/collects/macro-debugger/syntax-browser/prefs.ss @@ -3,8 +3,8 @@ (require scheme/class framework/framework "interfaces.ss" - "../util/notify.ss" - "../util/misc.ss") + unstable/gui/notify + unstable/gui/prefs) (provide prefs-base% syntax-prefs-base% syntax-prefs% diff --git a/collects/macro-debugger/syntax-browser/pretty-helper.ss b/collects/macro-debugger/syntax-browser/pretty-helper.ss index cf5e265a8b..73b22466e9 100644 --- a/collects/macro-debugger/syntax-browser/pretty-helper.ss +++ b/collects/macro-debugger/syntax-browser/pretty-helper.ss @@ -1,8 +1,8 @@ - #lang scheme/base (require scheme/class scheme/pretty - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) syntax/stx unstable/struct "interfaces.ss") diff --git a/collects/macro-debugger/syntax-browser/properties.ss b/collects/macro-debugger/syntax-browser/properties.ss index 63176ba9c2..f6a1a9d70a 100644 --- a/collects/macro-debugger/syntax-browser/properties.ss +++ b/collects/macro-debugger/syntax-browser/properties.ss @@ -1,8 +1,8 @@ - #lang scheme/base (require scheme/class scheme/gui - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) "interfaces.ss" "util.ss" "../util/mpi.ss") diff --git a/collects/macro-debugger/syntax-browser/syntax-snip.ss b/collects/macro-debugger/syntax-browser/syntax-snip.ss index d002b16507..7aeba5139d 100644 --- a/collects/macro-debugger/syntax-browser/syntax-snip.ss +++ b/collects/macro-debugger/syntax-browser/syntax-snip.ss @@ -1,13 +1,13 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) scheme/match scheme/list mzlib/string mred framework - "../util/notify.ss" + unstable/gui/notify "interfaces.ss" "display.ss" "controller.ss" diff --git a/collects/macro-debugger/syntax-browser/text.ss b/collects/macro-debugger/syntax-browser/text.ss index b6f30f1cc2..72193dc326 100644 --- a/collects/macro-debugger/syntax-browser/text.ss +++ b/collects/macro-debugger/syntax-browser/text.ss @@ -5,7 +5,7 @@ scheme/gui drscheme/arrow framework/framework - "../util/notify.ss") + unstable/gui/notify) (provide text:hover<%> text:hover-identifier<%> diff --git a/collects/macro-debugger/syntax-browser/widget.ss b/collects/macro-debugger/syntax-browser/widget.ss index f32e001206..7685f8f6a4 100644 --- a/collects/macro-debugger/syntax-browser/widget.ss +++ b/collects/macro-debugger/syntax-browser/widget.ss @@ -1,4 +1,3 @@ - #lang scheme/base (require scheme/class mred @@ -6,7 +5,8 @@ scheme/list scheme/match syntax/id-table - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) "interfaces.ss" "controller.ss" "display.ss" diff --git a/collects/macro-debugger/util/misc.ss b/collects/macro-debugger/util/misc.ss deleted file mode 100644 index 4790f20a21..0000000000 --- a/collects/macro-debugger/util/misc.ss +++ /dev/null @@ -1,25 +0,0 @@ - -#lang scheme/base -(require (for-syntax scheme/base) - scheme/class - framework/framework) -(provide closure-mixin - pref:get/set) - -(define-syntax pref:get/set - (syntax-rules () - [(_ get/set prop) - (define get/set - (case-lambda - [() (preferences:get 'prop)] - [(newval) (preferences:set 'prop newval)]))])) - -(define-syntax (closure-mixin stx) - (syntax-case stx () - [(closure-mixin interfaces [name proc] ...) - (with-syntax ([(iname ...) (generate-temporaries #'(name ...))]) - #'(let ([iname proc] ...) - (mixin () interfaces - (define/public (name . args) (apply iname args)) - ... - (super-new))))])) diff --git a/collects/macro-debugger/view/debug.ss b/collects/macro-debugger/view/debug.ss index 1b12f0f7ab..dff2ec1061 100644 --- a/collects/macro-debugger/view/debug.ss +++ b/collects/macro-debugger/view/debug.ss @@ -1,8 +1,8 @@ - #lang scheme/base (require scheme/pretty scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) "interfaces.ss" "debug-format.ss" "prefs.ss" diff --git a/collects/macro-debugger/view/extensions.ss b/collects/macro-debugger/view/extensions.ss index 64a8779b58..1894f8074a 100644 --- a/collects/macro-debugger/view/extensions.ss +++ b/collects/macro-debugger/view/extensions.ss @@ -1,7 +1,9 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:] + [send*/i send*:] + [init-field/i init-field:]) scheme/unit scheme/list scheme/match @@ -20,7 +22,7 @@ "../model/trace.ss" "../model/steps.ss" "cursor.ss" - "../util/notify.ss") + unstable/gui/notify) (provide stepper-keymap% stepper-syntax-widget%) diff --git a/collects/macro-debugger/view/frame.ss b/collects/macro-debugger/view/frame.ss index 9c5eb54f9b..301bcf4727 100644 --- a/collects/macro-debugger/view/frame.ss +++ b/collects/macro-debugger/view/frame.ss @@ -1,7 +1,8 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [define/i define:] + [send/i send:]) scheme/unit scheme/list scheme/file @@ -21,7 +22,7 @@ "../model/trace.ss" "../model/steps.ss" "cursor.ss" - "../util/notify.ss") + unstable/gui/notify) (provide macro-stepper-frame-mixin) (define (macro-stepper-frame-mixin base-frame%) diff --git a/collects/macro-debugger/view/hiding-panel.ss b/collects/macro-debugger/view/hiding-panel.ss index be6b24890b..6522fcd23b 100644 --- a/collects/macro-debugger/view/hiding-panel.ss +++ b/collects/macro-debugger/view/hiding-panel.ss @@ -1,14 +1,15 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:] + [init-field/i init-field:]) scheme/gui scheme/list syntax/boundmap "interfaces.ss" "../model/hiding-policies.ss" "../util/mpi.ss" - "../util/notify.ss") + unstable/gui/notify) (provide macro-hiding-prefs-widget%) (define mode:disable "Disable") diff --git a/collects/macro-debugger/view/interfaces.ss b/collects/macro-debugger/view/interfaces.ss index 4c7ddae67f..747c930cf8 100644 --- a/collects/macro-debugger/view/interfaces.ss +++ b/collects/macro-debugger/view/interfaces.ss @@ -1,6 +1,5 @@ - #lang scheme/base -(require macro-debugger/util/class-iop +(require unstable/class-iop (prefix-in sb: "../syntax-browser/interfaces.ss")) (provide (all-defined-out)) diff --git a/collects/macro-debugger/view/prefs.ss b/collects/macro-debugger/view/prefs.ss index 2986b1931c..5dd1bf0d74 100644 --- a/collects/macro-debugger/view/prefs.ss +++ b/collects/macro-debugger/view/prefs.ss @@ -4,8 +4,8 @@ framework/framework "interfaces.ss" "../syntax-browser/prefs.ss" - "../util/notify.ss" - "../util/misc.ss") + unstable/gui/notify + unstable/gui/prefs) (provide pref:macro-step-limit macro-stepper-config-base% macro-stepper-config/prefs% diff --git a/collects/macro-debugger/view/step-display.ss b/collects/macro-debugger/view/step-display.ss index 5a9196a942..65be319aa7 100644 --- a/collects/macro-debugger/view/step-display.ss +++ b/collects/macro-debugger/view/step-display.ss @@ -1,7 +1,9 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:] + [send*/i send*:] + [init-field/i init-field:]) scheme/unit scheme/list scheme/match @@ -20,7 +22,7 @@ "../model/reductions-config.ss" "../model/reductions.ss" "../model/steps.ss" - "../util/notify.ss" + unstable/gui/notify (prefix-in sb: "../syntax-browser/interfaces.ss") "cursor.ss" "debug-format.ss") diff --git a/collects/macro-debugger/view/stepper.ss b/collects/macro-debugger/view/stepper.ss index ccc89924c3..ecab49d28f 100644 --- a/collects/macro-debugger/view/stepper.ss +++ b/collects/macro-debugger/view/stepper.ss @@ -1,7 +1,10 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [define/i define:] + [send/i send:] + [send*/i send*:] + [init-field/i init-field:]) scheme/unit scheme/list scheme/match @@ -22,7 +25,7 @@ "../model/reductions.ss" "../model/steps.ss" "cursor.ss" - "../util/notify.ss" + unstable/gui/notify (only-in mzscheme [#%top-interaction mz-top-interaction])) (provide macro-stepper-widget% macro-stepper-widget/process-mixin) diff --git a/collects/macro-debugger/view/term-record.ss b/collects/macro-debugger/view/term-record.ss index 2fc563725e..fe404adf75 100644 --- a/collects/macro-debugger/view/term-record.ss +++ b/collects/macro-debugger/view/term-record.ss @@ -1,6 +1,9 @@ #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [define/i define:] + [send/i send:] + [init-field/i init-field:]) scheme/unit scheme/list scheme/match @@ -22,7 +25,7 @@ "../model/reductions-config.ss" "../model/reductions.ss" "../model/steps.ss" - "../util/notify.ss" + unstable/gui/notify "cursor.ss" "debug-format.ss") diff --git a/collects/macro-debugger/view/view.ss b/collects/macro-debugger/view/view.ss index 3d831bdee4..7162a983a6 100644 --- a/collects/macro-debugger/view/view.ss +++ b/collects/macro-debugger/view/view.ss @@ -1,7 +1,7 @@ - #lang scheme/base (require scheme/class - macro-debugger/util/class-iop + (rename-in unstable/class-iop + [send/i send:]) scheme/pretty scheme/gui framework/framework diff --git a/collects/macro-debugger/util/class-iop.ss b/collects/unstable/class-iop.ss similarity index 90% rename from collects/macro-debugger/util/class-iop.ss rename to collects/unstable/class-iop.ss index ae89b2fa39..a6a07e3279 100644 --- a/collects/macro-debugger/util/class-iop.ss +++ b/collects/unstable/class-iop.ss @@ -3,20 +3,21 @@ (for-syntax scheme/base syntax/parse unstable/syntax - "class-ct.ss")) + "private/class-iop-ct.ss")) (provide define-interface define-interface/dynamic define-interface-expander - send: - send*: - send/apply: + (rename-out [send: send/i] + [send*: send*/i] + [send/apply: send/apply/i] - define: - lambda: - init: - init-field: - init-private:) + [define: define/i] + #| lambda: |# + + [init: init/i] + [init-field: init-field/i] + [init-private: init-private/i])) ;; Configuration (define-for-syntax warn-on-dynamic-interfaces? #f) @@ -65,7 +66,7 @@ (begin-for-syntax (define (check-method-in-interface for-whom method si) (unless (member (syntax-e method) (static-interface-members si)) - (raise-syntax-error for-whom + (raise-syntax-error (syntax-e for-whom) "method not in static interface" method)))) @@ -74,7 +75,7 @@ (define-syntax (send: stx) (syntax-parse stx [(send: obj:expr iface:static-interface method:id . args) - (begin (check-method-in-interface 'send: #'method (attribute iface.value)) + (begin (check-method-in-interface #'send: #'method (attribute iface.value)) (syntax/loc stx (send (check-object<:interface send: obj iface) method . args)))])) @@ -83,7 +84,7 @@ (syntax-parse stx [(send*: obj:expr iface:static-interface (method:id . args) ...) (begin (for ([method (syntax->list #'(method ...))]) - (check-method-in-interface 'send*: method (attribute iface.value))) + (check-method-in-interface #'send*: method (attribute iface.value))) (syntax/loc stx (send* (check-object<:interface send*: obj iface) (method . args) ...)))])) @@ -91,9 +92,9 @@ (define-syntax (send/apply: stx) (syntax-parse stx [(send/apply: obj:expr iface:static-interface method:id . args) - (begin (check-method-in-interface 'send/apply: #'method (attribute iface.value)) + (begin (check-method-in-interface #'send/apply: #'method (attribute iface.value)) (syntax/loc stx - (send/apply (check-object<:interface send/apply obj iface) + (send/apply (check-object<:interface send/apply: obj iface) method . args)))])) ;; diff --git a/collects/macro-debugger/util/notify.ss b/collects/unstable/gui/notify.ss similarity index 99% rename from collects/macro-debugger/util/notify.ss rename to collects/unstable/gui/notify.ss index 2eb7d9c57c..b73efc59e3 100644 --- a/collects/macro-debugger/util/notify.ss +++ b/collects/unstable/gui/notify.ss @@ -3,7 +3,6 @@ (require (for-syntax scheme/base unstable/syntax) scheme/list scheme/class - macro-debugger/util/class-iop scheme/gui) (provide define/listen field/notify diff --git a/collects/unstable/gui/prefs.ss b/collects/unstable/gui/prefs.ss new file mode 100644 index 0000000000..ebc5aa07f3 --- /dev/null +++ b/collects/unstable/gui/prefs.ss @@ -0,0 +1,13 @@ + +#lang scheme/base +(require (for-syntax scheme/base) + framework/framework) +(provide pref:get/set) + +(define-syntax pref:get/set + (syntax-rules () + [(_ get/set prop) + (define get/set + (case-lambda + [() (preferences:get 'prop)] + [(newval) (preferences:set 'prop newval)]))])) diff --git a/collects/macro-debugger/util/class-ct.ss b/collects/unstable/private/class-iop-ct.ss similarity index 100% rename from collects/macro-debugger/util/class-ct.ss rename to collects/unstable/private/class-iop-ct.ss diff --git a/collects/unstable/scribblings/class-iop.scrbl b/collects/unstable/scribblings/class-iop.scrbl new file mode 100644 index 0000000000..93ce21ecb1 --- /dev/null +++ b/collects/unstable/scribblings/class-iop.scrbl @@ -0,0 +1,125 @@ +#lang scribble/manual +@(require scribble/eval + (for-label unstable/class-iop + scheme/class + scheme/contract + scheme/base)) + +@title[#:tag "class-iop"]{Interface-Oriented Programming for Classes} + +@(define the-eval (make-base-eval)) +@(the-eval '(require scheme/class unstable/class-iop)) + +@defmodule[unstable/class-iop] + +@defform[(define-interface name-id (super-ifc-id ...) (method-id ...))]{ + +Defines @scheme[name-id] as a static interface extending the +interfaces named by the @scheme[super-ifc-id]s and containing the +methods specified by the @scheme[method-id]s. + +A static interface name is used by the checked method call variants +(@scheme[send/i], @scheme[send*/i], and @scheme[send/apply/i]). When +used as an expression, a static interface name evaluates to an +interface value. + +@examples[#:eval the-eval +(define-interface stack<%> () (empty? push pop)) +stack<%> +(define stack% + (class* object% (stack<%>) + (define items null) + (define/public (empty?) (null? items)) + (define/public (push x) (set! items (cons x items))) + (define/public (pop) (begin (car items) (set! items (cdr items)))) + (super-new))) +] +} + +@defform[(define-interface/dynamic name-id ifc-expr (method-id ...))]{ + +Defines @scheme[name-id] as a static interface with dynamic +counterpart @scheme[ifc-expr], which must evaluate to an interface +value. The static interface contains the methods named by the +@scheme[method-id]s. A run-time error is raised if any +@scheme[method-id] is not a member of the dynamic interface +@scheme[ifc-expr]. + +Use @scheme[define-interface/dynamic] to wrap interfaces from other +sources. + +@examples[#:eval the-eval +(define-interface/dynamic object<%> (class->interface object%) ()) +object<%> +] +} + +@defform[(send/i obj-exp static-ifc-id method-id arg-expr ...)]{ + +Checked variant of @scheme[send]. + +The argument @scheme[static-ifc-id] must be defined as a static +interface. The method @scheme[method-id] must be a member of the +static interface @scheme[static-ifc-id]; otherwise a compile-time +error is raised. + +The value of @scheme[obj-expr] must be an instance of the interface +@scheme[static-ifc-id]; otherwise, a run-time error is raised. + +@examples[#:eval the-eval +(define s (new stack%)) +(send/i s stack<%> push 1) +(send/i s stack<%> popp) +(send/i (new object%) stack<%> push 2) +] +} + +@defform[(send*/i obj-expr static-ifc-id (method-id arg-expr ...) ...)]{ + +Checked variant of @scheme[send*]. + +@examples[#:eval the-eval +(send*/i s stack<%> + (push 2) + (pop)) +] +} + +@defform[(send/apply/i obj-expr static-ifc-id method-id arg-expr ... list-arg-expr)]{ + +Checked variant of @scheme[send/apply]. + +@examples[#:eval the-eval +(send/apply/i s stack<%> push (list 5)) +] +} + +@defform[(define/i id static-ifc-id expr)]{ + +Checks that @scheme[expr] evaluates to an instance of +@scheme[static-ifc-id] before binding it to @scheme[id]. If +@scheme[id] is subsequently changed (with @scheme[set!]), the check is +performed again. + +No dynamic object check is performed when calling a method (using +@scheme[send/i], etc) on a name defined via @scheme[define/i]. + +} + +@deftogether[[ +@defform[(init/i (id static-ifc-id maybe-default-expr) ...)] +@defform[(init-field/i (id static-ifc-id maybe-default-expr) ...)] +@defform/subs[(init-private/i (id static-ifc-id maybe-default-expr) ...) + ([maybe-default-expr (code:blank) + default-expr])]]]{ + +Checked versions of @scheme[init] and @scheme[init-field]. The value +attached to each @scheme[id] is checked against the given interface. + +No dynamic object check is performed when calling a method (using +@scheme[send/i], etc) on a name bound via one of these forms. Note +that in the case of @scheme[init-field/i] this check omission is +unsound in the presence of mutation from outside the class. This +should be fixed. + +} diff --git a/collects/unstable/scribblings/find.scrbl b/collects/unstable/scribblings/find.scrbl index b82de303c1..36ce5d2cbe 100644 --- a/collects/unstable/scribblings/find.scrbl +++ b/collects/unstable/scribblings/find.scrbl @@ -60,7 +60,7 @@ mutable table. [#:default default any/c (lambda () (error ....))]) any/c]{ -Like @scheme[find-first], but only returns the first match. If no +Like @scheme[find], but only returns the first match. If no matches are found, @scheme[default] is applied as a thunk if it is a procedure or returned otherwise. diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index 13e2d892b0..3dde2e3c66 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -83,6 +83,7 @@ Keep documentation and tests up to date. @include-section["poly-c.scrbl"] @include-section["mutated-vars.scrbl"] @include-section["find.scrbl"] +@include-section["class-iop.scrbl"] @;{--------} diff --git a/collects/unstable/struct.ss b/collects/unstable/struct.ss index dde3f1fc4a..1384d643fb 100644 --- a/collects/unstable/struct.ss +++ b/collects/unstable/struct.ss @@ -49,7 +49,7 @@ (define dummy-value (box 'dummy)) ;; struct->list : struct? -;; #:on-opaque? (or/c 'error 'return-false 'skip) +;; #:on-opaque (or/c 'error 'return-false 'skip) ;; -> (listof any/c) (define (struct->list s #:on-opaque [on-opaque 'error])