[plt-scheme] (provide ...) question

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue May 18 10:11:13 EDT 2010

I think this is a (known) bug in define-struct/contract.

Also consider exporting a contracted structure instead of defining a  
struct with a contract. Slightly different meanings but the former  
appears to be what you want.


On May 18, 2010, at 10:03 AM, Todd O'Bryan wrote:

> Whoops. I tried to simplify the example, and simplified it to the
> point where it works. It seems that the problem is actually when I try
> to use define-struct/contract:
>
> #lang scheme
> (provide (except-out (struct-out city-line)
>                    make-city-line)
>        (rename-out [better-make-city-line make-city-line]))
>
> (define-struct/contract city-line
>  ([city string?]
>   [state #px"[A-Z]{2}"]
>   [zip #px"\\d{5}"]
>   [zip+4 #px"\\d{4}"]))
>
> (define better-make-city-line
> (case-lambda
>   [(city state zip zip+4)
>    (make-city-line city state zip zip+4)]
>   [(city state zip)
>    (make-city-line city state zip "")]))
>
> causes the error:
>
> except-out: identifier to remove `make-city-line' not included in
> nested provide spec in: (struct-out city-line)
>
> Sorry for not checking my example!
> Todd
>
> On Tue, May 18, 2010 at 9:43 AM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>>
>> In what way doesn't this do "it"?
>>
>>
>> On May 18, 2010, at 8:44 AM, Todd O'Bryan wrote:
>>
>>> I have a struct that I'd like to provide from a module, but I'd like
>>> to provide a different constructor to modules that require it.  
>>> Here's
>>> a simple example:
>>>
>>> (define-struct city-line (city state zip zip+4))
>>>
>>> (define better-make-city-line
>>>  (case-lambda
>>>   [(city state zip zip+4)
>>>    (make-city-line city state zip zip+4)]
>>>   [(city state zip)
>>>    (make-city-line city state zip "")]))
>>>
>>> I tried this:
>>>
>>> (provide (except-out (struct-out city-line)
>>>                    make-city-line)
>>>        (rename-out [better-make-city-line make-city-line]))
>>>
>>> but that doesn't seem to do it.
>>>
>>> Is there a way to do such a thing? Am I close?
>>>
>>> Thanks,
>>> Todd
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>



Posted on the users mailing list.