[plt-scheme] attaching object names to values

From: Sam TH (samth at ccs.neu.edu)
Date: Sat Dec 6 18:18:08 EST 2008

On Sat, Dec 6, 2008 at 6:06 PM, Robby Findler <robby at cs.uchicago.edu> wrote:
> require/contract is given a name tho, isn't it? Why not use that name?

That's what I'm trying to figure out how to do. Is there some way to
pass the name to the contract constructors?  Would that work even
though the contract is an arbitrary expression?

Thanks again,
sam th

>
> Robby
>
> On Sat, Dec 6, 2008 at 4:57 PM, Sam TH <samth at ccs.neu.edu> wrote:
>> On Sat, Dec 6, 2008 at 11:55 AM, Robby Findler <robby at cs.uchicago.edu> wrote:
>>> I think there isn't one, but if you see how to make one, please let me know.
>>
>> It seems like a procedure that just changes the `object-name' of value
>> would be valuable.
>>
>>> FWIW, provide/contract does a better job than just `contract' and I
>>> believe would do what you want.
>>
>> Unfortunately, this is in the implementation of a `require/contract'
>> form, so I can't use `provide/contract'.
>>
>> Thanks,
>> sam th
>>
>>>
>>> Robby
>>>
>>> On Fri, Dec 5, 2008 at 12:44 PM, Sam TH <samth at ccs.neu.edu> wrote:
>>>> 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?
>>>>
>>>> Thanks,
>>>> --
>>>> sam th
>>>> samth at ccs.neu.edu
>>>> _________________________________________________
>>>>  For list-related administrative tasks:
>>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> sam th
>> samth at ccs.neu.edu
>>
>>
>



-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.