[plt-scheme] Higher-order contracts for variable-arity functions

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu May 25 16:16:32 EDT 2006

To specifically respond to your points:

On 5/25/06, Robby Findler <robby at cs.uchicago.edu> wrote:
> At Thu, 25 May 2006 15:47:03 -0400, "Carl Eastlund" wrote:
> > I am not trying to apply a contract to a list.  I do not want to use
> > listof - my point is not to change listof, but to write an alternative
> > so that I may avoid using listof.
> You need an alternate lambda too; hence my suggestion to petition the
> R6RS authors.

I am specifically writing this for variable-arity lambda, written
(lambda args EXPR ...) or (lambda (a b c ... . rest) EXPR ...).  Why
would I need any more than that?

> > In my interpretation, the fact that
> > the arguments are delivered in a list is a byproduct.  Only the list's
> > elements are actually arguments to the function, so I want to apply a
> > contract to the arguments that are passed in.  Conceptually, I want to
> > consider the contract as coming before the "list" is built around the
> > rest arguments.  Pragmatically, this may mean the contract system has
> > to destructure the list, apply contracts to each element, and rebuild
> > the list.  This should be safe, though - the list is fresh anyway,
> > replacing it with a different one shouldn't change anything.
> The contract system can't tell that the list won't be mutated/

Why should it ever matter if the list is mutated?  I want to apply the
contract to the functions.  That they happen to comprise the list's
initial contents is incidental. If the functions are removed from the
list, I want the contract to stay on them (which is how the contracts
work anyway).  If other functions or values are put in the list, I do
not want any contract put on them (which is how the contracts work
anyway).  What is the difficulty?

Carl Eastlund
"Cynical, but technically correct."

Posted on the users mailing list.