[plt-scheme] How to display constructor form in PrettyBig

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Apr 5 13:48:08 EDT 2010

Just write a macro that always adds #:transparent and require it as a  
teachpack.


On Apr 5, 2010, at 1:37 PM, Barry Brown wrote:

> Thanks for the tip. Using #:transparent with #lang scheme works.  
> I've been having my students use PrettyBig all semester since I  
> didn't really know what #lang scheme did until just recently. I was  
> hoping there was some module I could require to automatically print  
> out structures when the output style of "constructor" is selected.
>
> Is there a way to do it without having to add #:transparent to the  
> structure definition?
>
> -B
>
> On Apr 5, 2010, at 9:57 AM, Robby Findler wrote:
>
>> I think you want to make the struct transparent:
>>
>> (define-struct node (value left right) #:transparent)
>>
>> is how you do that in "#lang scheme", but in pretty big you may or  
>> may
>> not be using that define-struct.
>>
>> If you can, your best long-term route is to avoid Pretty Big and  
>> write
>> files with a language specification at the top. In that case you  
>> might
>> write:
>>
>> #lang scheme
>> (define-struct node (value left right) #:transparent)
>>
>> Or this one might be the one you want, depending on the rest of  
>> your program:
>>
>> #lang mzscheme
>> (define-struct node (value left right) (make-inspector))
>>
>> Note that after you do this, you should adjust the language in your
>> language dialog to the "Module" language (for older versions) or
>> choose the "Use the language defined in the source" radio button (for
>> the most recent version).
>>
>> hth,
>> Robby
>>
>> On Mon, Apr 5, 2010 at 11:48 AM, Barry Brown <barry at cs.sierracollege.edu 
>> > wrote:
>>> I'm sorry; I should have mentioned in my original email that I  
>>> have tried that. It still prints only (make-node ...)
>>>
>>> -B
>>>
>>> On Apr 5, 2010, at 9:38 AM, Matthias Felleisen wrote:
>>>
>>>>
>>>> Open the Language Dialog. Choose constructor-style printing.  
>>>> Okay. Enjoy.
>>>>
>>>>
>>>> On Apr 5, 2010, at 12:27 PM, Barry Brown wrote:
>>>>
>>>>> How do I get PrettyBig or #lang scheme to display structures  
>>>>> using the complete constructor form the way Beginning Student  
>>>>> does?
>>>>>
>>>>> I want to do this:
>>>>> (define-struct node (value left right))
>>>>> (make-node 10 (make-node 5 empty empty) empty)
>>>>>
>>>>> and have it display as:
>>>>> (make-node 10 (make-node 5 empty empty) empty)
>>>>>
>>>>> instead of:
>>>>> (make-node ...)
>>>>>
>>>>> I have tried (require syntax/struct) and (require syntax/to- 
>>>>> string) to no avail.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> -B_________________________________________________
>>>>> For list-related administrative tasks:
>>>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>



Posted on the users mailing list.