[racket] procedure contract for "at least N arguments, possibly more"

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Fri Jun 8 21:57:05 EDT 2012

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
                (lambda (in) ;; This is P1.
                  (syntax-parse (read-syntax 'my-source in)
                    ((A B C) (values #'A #'B #'C))))
                (lambda (in out a-stx b-stx c-stx) ;; This is P2.
                  (progedit in
                            #: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.

Neil V.

Posted on the users mailing list.