diff --git a/collects/frtime/mzscheme-core.ss b/collects/frtime/mzscheme-core.ss index 42942501dd..1b14c0d08b 100644 --- a/collects/frtime/mzscheme-core.ss +++ b/collects/frtime/mzscheme-core.ss @@ -111,21 +111,27 @@ (define any-nested-reactivity? (opt-lambda (obj [mem empty]) - (cond - [(memq obj mem) #f] - [(behavior? obj) #t] - [(cons? obj) - (let ([mem (cons obj mem)]) - (or (any-nested-reactivity? (car obj) mem) - (any-nested-reactivity? (cdr obj) mem)))] - [(struct? obj) - (let*-values ([(info skipped) (struct-info obj)] - [(name init-k auto-k acc mut immut sup skipped?) (struct-type-info info)] - [(ctor) (struct-type-make-constructor info)]) - (ormap (lambda (i) (any-nested-reactivity? (acc obj i) (cons obj mem))) - (build-list (+ auto-k init-k) (lambda (x) x))))] - [(vector? obj) (vector-any (lambda (o) (any-nested-reactivity? o (cons obj mem))) obj)] - [else #f]))) + (with-handlers ((exn:fail? + (lambda (e) + (fprintf + (current-error-port) + "you've encountered a bug in frtime. please send a report to the plt-scheme mailing list.~nexn: ~a~n" + e) #f))) + (cond + [(memq obj mem) #f] + [(behavior? obj) #t] + [(cons? obj) + (let ([mem (cons obj mem)]) + (or (any-nested-reactivity? (car obj) mem) + (any-nested-reactivity? (cdr obj) mem)))] + [(struct? obj) + (let*-values ([(info skipped) (struct-info obj)] + [(name init-k auto-k acc mut immut sup skipped?) (struct-type-info info)] + [(ctor) (struct-type-make-constructor info)]) + (ormap (lambda (i) (any-nested-reactivity? (acc obj i) (cons obj mem))) + (build-list init-k (lambda (x) x))))] + [(vector? obj) (vector-any (lambda (o) (any-nested-reactivity? o (cons obj mem))) obj)] + [else #f])))) (define (deep-value-now/update-deps obj deps table) (cond @@ -147,8 +153,7 @@ (cons car-val cdr-val)))] ; won't work in the presence of super structs or immutable fields [(struct? obj) - obj - #;(let*-values ([(info skipped) (struct-info obj)] + (let*-values ([(info skipped) (struct-info obj)] [(name init-k auto-k acc mut! immut sup skipped?) (struct-type-info info)] [(ctor) (struct-type-make-constructor info)] [(indices) (build-list init-k identity)] diff --git a/collects/frtime/mzscheme-utils.ss b/collects/frtime/mzscheme-utils.ss index 3544d42d21..edaba7279d 100644 --- a/collects/frtime/mzscheme-utils.ss +++ b/collects/frtime/mzscheme-utils.ss @@ -183,16 +183,28 @@ (values acc (car lst)) (split-list (append acc (list (car lst))) (cdr lst)))) + (define (all-but-last lst) + (if (null? (cdr lst)) + '() + (cons (car lst) (all-but-last (cdr lst))))) + + (define frp:apply/const-fn + (lambda (fn . args) + (let ([first-args (all-but-last args)] + [last-args (first (last-pair args))]) + (if (behavior? last-args) + (super-lift + (lambda (last-args) + (apply apply fn (append first-args (list last-args)))) + last-args) + (apply apply fn args))))) + (define frp:apply (lambda (fn . args) - (if (behavior? args) - (super-lift - (lambda (args) - (if (and (list? args) (list? (last-pair args))) - (apply apply fn args) - undefined)) - args) - (apply apply fn args)))) + (if (behavior? fn) + (super-lift (lambda (fn) (apply frp:apply/const-fn fn args)) fn) + (apply frp:apply/const-fn fn args)))) + #| ;; taken from startup.ss (define-syntax frp:case