Robby Findler wrote at 06/08/2012 09:31 PM:
To get a little more context: what happens if P1 returns different
numbers of values each time it is called?

That would be a programming error by the user of this library, and I'm fine with them getting a non-contracts runtime error.

I think my root problem here is that I'm trying to make the contract stuff let me not actually use the contract stuff much. I'm doing this because my documentation thing encourages the use of contracts.

Anyway, a more concrete example of why I wanted this is below. I thought I'd be cute, and have "progedit-file" provide a convenient functional way for people to communicate arbitrary info like syntax objects and hashes from P1 to P2.

(progedit-file actual-path
               #:read
               (lambda (in) ;; This is P1.
                 (syntax-parse (read-syntax 'my-source in)
                   ((A B C) (values #'A #'B #'C))))
               #:write
               (lambda (in out a-stx b-stx c-stx) ;; This is P2.
                 (progedit in
                           out
                           #:inserts  `(((after  ,b-stx) " After")
                                        ((before ,b-stx) "Before ")))
                           #:replaces `((,b-stx "Replaced")))))

Also, perhaps not the best thing (pending the answer above), you can
write a predicate contract that gets the procedure-arity result and do
what you want with it. That doesn't work well if you want to actually
put contracts on the two arguments, tho.

I think I'll just use "procedure?" in the contract. Or get rid of the cute passing of info.

Thanks,
Neil V.

____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to