> 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?])
       ([y real?])
       [result boolean?]
       #:post (x y result)
       (equal? result (< (sqr (if (unsupplied-arg? y) (default-y x) y)) x)))
  (> x (sqr y)))

(greater-than-square? 10)

> 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 ...)
                      body ...)
    (define (fn args ...) (fn/impl args ...))
    (with-contract fn
                   ([fn/impl ctc])
                   ; #:freevar fn ctc ;;;; **** now you see it checked only 
                   (define (fn/impl args ...)
                     body ...))))

> 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 

— Matthias

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 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to