> On Jun 6, 2016, at 10:24 PM, Alex Knauth <alexan...@knauth.org> wrote:
> 
> If I run this program:
> 
> #lang racket
> (set 1 2 3)
> 
> It prints out the value:
> 
> (set 1 2 3)
> 
> That's wonderful! It uses nice constructor-style printing, just like I 
> wanted. That was without changing the printing settings from the default 
> print mode.
> 
> However, if I change DrRacket's printing settings to use constructor-style 
> printing instead, I get this:
> 
> (immutable-custom-set ...)
> 
> The constructor-style printing mode in DrRacket uses `print-convert` from 
> `mzlib/pconvert` to do this, and the `racket/set` library already uses 
> `gen:custom-write` for constructor-style printing.
> 
> Should `racket/set` sets also use a property similar to 
> `prop:print-converter` that `print-convert` can recognize and use? Or should 
> sets be another case in the implementation of `print-convert`?

Would something like a `prop:constructor-style-printer` property make sense 
here? It would imply `prop:custom-write` with a 
`make-constructor-style-printer` value, so it would also cooperate with pretty 
printing. And anything like `print-convert` that wants to deal with 
s-expressions could recognize this property and use it to do the right thing.

> (struct point (x y)
    #:property prop:constructor-style-printer
    (list
     (lambda (p) 'point)
     (lambda (p) (list (point-x p) (point-y p)))))
> (print (point 1 2))
(point 1 2)
> (print-convert (point 1 2))
(list 'point 1 2)
> (parameterize ([pretty-print-columns 10])
    (pretty-print (point 3000000 4000000)))
(point
 3000000
 4000000)

Does this seem like something that should be added to `racket/struct` next to 
`make-constructor-style-printer`?

> Alex Knauth

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to