[racket] contracts on liberal function inputs: avoiding duplicate effort

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Mon Nov 18 13:59:28 EST 2013

On 2013-11-18 09:03:19 -0800, Matthew Butterick wrote:
> In a function that permits liberal inputs, I often find that the input
> processing I do in a contract is duplicated at the beginning of the
> body of the function. Is this avoidable?

FWIW, I came across the same issue when writing contracts related to IP
address operations.

To ensure that an input string represents a valid address, the contract
needs to parse the string. The constructor for the address structure
also needs to parse the string to get the data, so it's redundant.

(I didn't come up with a nice solution though)

Cheers,
Asumu

Posted on the users mailing list.