This question comes from someone else on Stack Overflow, which they
asked here: http://stackoverflow.com/q/41144374/465378

I think it’s likely that the people who can answer this are probably
only on the mailing list, though, so I figured I’d ask it here.

Basically, the ->i contract applies contract projections more than
once, despite the fact that it seems unnecessary. Here’s the example
provided in the question:

  (define/contract (foo x y z)
    (->i ([x       (λ (x) (begin (displayln 0) #t))]
          [y (x)   (λ (y) (begin (displayln 1) #t))]
          [z (x y) (λ (z) (begin (displayln 2) #t))])
         any)
    #t)

  (foo 1 2 3)

The above example prints the following when run:

  0
  0
  1
  1
  2
  #t

This indicates that values used dependently for determining other
contracts cause their contracts to be applied more than once. The
above example only uses flat contracts, but I tested with a
side-effectful impersonator contract and got the same result.

After some very simple pondering, I couldn’t come up with a situation
in which applying the contracts more than once would be necessary,
and this could obviously have a performance penalty given that ->i
is already a fairly slow contract. Is this a bug in ->i, or is it
necessary or intentional behavior? If the latter, why is it necessary?

Alexis

-- 
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