> On May 7, 2017, at 1:26 AM, Daniel Prager <daniel.a.pra...@gmail.com> wrote:
> Putting this new set-up through its paces I think I've found a few issues:
> 1. Default argument goes missing from post-condition, leading to an
> unexpected error …
(define (default-y x) 0)
(define/contract (greater-than-square? x [y (default-y x)])
(->i ([x real?])
#:post (x y result)
(equal? result (< (sqr (if (unsupplied-arg? y) (default-y x) y)) x)))
(> x (sqr y)))
> 3. post-conditions appear to be called twice ...
> Is there a double boundary crossing on post-conditions?
Yes! Your syntax rule says to check the post-condition twice:
(define-syntax-rule (define/tight (fn args ...)
(define (fn args ...) (fn/impl args ...))
; #:freevar fn ctc ;;;; **** now you see it checked only
(define (fn/impl args ...)
> Finally, some timings.
Measure with outer contract and remove the inner define/tight. If you wrote
this algorithm with a loop in Eiffel, instead of a tail-recursive function, you
wouldn’t check the invariant for every loop iteration either
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.