Thanks Ryan!

On Thursday, September 3, 2020 at 5:47:50 AM UTC-4 rmculp...@gmail.com 
wrote:

> The Racket printer uses a separate property to determine whether a struct 
> is quotable. If you add 
>
>   #:property prop:custom-print-quotable 'never
>
> to the declarations of Int2 and Prim2, your program should produce the 
> output you expect. I'll add a note to the docs for 
> make-constructor-style-printer.
>
> Ryan
>
>
> On Wed, Sep 2, 2020 at 10:07 PM Jeremy Siek <jerem...@gmail.com> wrote:
>
>> I'm seeing some bad behavior from make-constructor-style-printer when
>> there are lists mixed in with the structs. It seems to switch from print 
>> mode to
>> write mode when going under a list. Whereas the default printer for 
>> transparent structs gets this right. The following program demonstrates the 
>> difference/problem.
>> Any thoughts on how to get the make-constructor-style-printer to behave
>> properly?
>>
>> #lang racket
>> (require racket/struct)
>>
>> (struct Int1 (value) #:transparent)
>> (struct Prim1 (op arg*) #:transparent)
>>
>> (struct Int2 (value) #:transparent
>>   #:methods gen:custom-write
>>   [(define write-proc
>>      (make-constructor-style-printer
>>       (lambda (obj) 'Int2)
>>       (lambda (obj) (list (Int2-value obj)))))])
>> (struct Prim2 (op arg*) #:transparent
>>   #:methods gen:custom-write
>>   [(define write-proc
>>      (make-constructor-style-printer
>>       (lambda (obj) 'Prim2)
>>       (lambda (obj) (list (Prim2-op obj) (Prim2-arg* obj)))))])
>>
>> (define p1 (Prim1 '+ (list (Int1 1) (Int1 2))))
>> (print p1)(newline)
>>
>> (define p2 (Prim2 '+ (list (Int2 1) (Int2 2))))
>> (print p2)(newline)
>>
>> The output is:
>>
>> (Prim1 '+ (list (Int1 1) (Int1 2)))
>> (Prim2 '+ '(#<Int2: 1> #<Int2: 2>))
>>
>> -Jeremy
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/bdeb1052-ea25-4dc0-8292-a13d15bf7870n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/bdeb1052-ea25-4dc0-8292-a13d15bf7870n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f2e7dee9-af4b-4337-92c2-2b5790441b73n%40googlegroups.com.

Reply via email to