[plt-scheme] attaching object names to values

From: Sam TH (samth at ccs.neu.edu)
Date: Fri Dec 5 13:44:28 EST 2008

The contract system uses the `object-name' of predicates to print out
their names in error messages.  But this can be useless if the
predicate itself is wrapped in a contract.  This program shows the
problem pretty well:

#lang scheme

(define x? (contract (-> any/c boolean?) (lambda (x) #t) 'here 'there))

(define my/c (-> x? x?))

(contract my/c 5 'foo 'bar)

It gives a contract error referencing "unsaved-editorx:y:z", instead
of "x?".  Unfortunately, there seems to be nothing that I can do to
change the object-name of the contract value (except eta-expand).
Notably, the inferred-name syntax property doesn't work, since the
actual lambda expression isn't available (it's in the contract
library). Is there a solution here I'm missing?

sam th
samth at ccs.neu.edu

Posted on the users mailing list.