[plt-dev] weird error; contracts for xml error

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat May 30 17:38:27 EDT 2009

On May 30, 2009, at 3:46 PM, Jay McCarthy wrote:

>> here is a contract error, which I believes illustrates the  
>> "pressure of
>> contracts" conjecture:
>>
>>> Making Web pages in /Users/matthias/0Unison/0Web/107-f08/
>>> (file "/Users/matthias/plt/collects/xml/private/reader.ss") broke  
>>> the
>>> contract
>>>  (->
>>>   (or/c location? symbol? #f)
>>>   (or/c location? symbol? #f)
>>>   symbol?
>>>   (or/c permissive/c string?)
>>>   attribute?)
>>>  on make-attribute; not in permissive mode
>>
>> So this seems to mean a (permissive? #t) is missing from  
>> reader.ss. I added
>> it and 'it works now' but I don't think that's the proper way to  
>> go about
>> it.
>
> I don't know what the pressure of contracts is, but the XML parameter
> permissive? is basically only used by the XML tool in DrScheme to put
> the special Scheme boxes inside of the XML behind the XML box. You
> should put it in _your_ code, not the XML collection if you need it to
> be in permissive mode

--> Robby explained the principle, so let me apply it to this situation:
I wrote a script that traverses a large directory tree and dynamically
requires an index.ss files in each directory if it finds one. I am
guessing this means two or three dozen files of between 100 and 500
lines of code. One of those invocations raised an error and blamed
your module.

My conjecture was what you responded with. Somehow I should set the
permissive flag when the xml library is required. BUT nevertheless
the way you wrote the contract, you got blamed, meaning you should
protect your library better with an "entry" contract so that your
"exit" contract doesn't trigger the exception.

--> I naturally first looked up permissive (and was surprised to
find something). Then I ran (permissive? #t) in the module that
requires yours --- but the contract failure didn't go away. So I
moved that expression to your module and voila things went thru.

I do not know what went wrong with setting the permissive parameter
in my module. And I don't have time to find out.

--> One minor thing: I suggest not using a "?" at the end of the
name for a parameter. ? suggests a predicate and it's difficult
to get used to the idea that it isn't. -- Matthias





Posted on the dev mailing list.