On Fri, Jun 10, 2016 at 11:51 AM, Alex Knauth <alexan...@knauth.org> wrote: > >> On Jun 10, 2016, at 11:18 AM, Robby Findler <ro...@eecs.northwestern.edu> >> wrote: >> >> I view the mechanism that DrRacket's constructor-style printing uses >> is a kind of add-on layer to avoid incompatibility with standard >> Scheme-style printing that we were using back in the day. So, it is >> useful for a small set of classes of values and that for modern things >> in Racket (like sets, where we just design in a "constructor style" >> printing from the get go) we should just use the printing style that's >> in place there. >> >> In that spirit, I think the right approach here is to find a way to >> get the constructor-style code to just decide "oh, this isn't one of >> the small set of old-style values; I'll just print the way it wants to >> be printed". Perhaps the right approach is (yet) a(nother) parameter >> that causes the constructor-style code to handle only a fixed set of >> things and then defer to the existing printer. > > I was thinking of that too, but the problem is that the constructor-style > printing deals with s-expressions, while the existing printer for sets deals > with output ports.
Maybe we just need to implement the constructor style printing differently? Perhaps something that cooperates with the pretty-printer instead? After all, the set of things that get special printing is small(ish) and fixed. > For something to cooperate with the constructor-style printer, something like > the set printer would have to give it the a symbol for the constructor and a > list of the sub-expressions for that constructor, which the constructor-style > printer could convert to s-expressions recursively. > > Would something like that work? > > (serializable-struct immutable-custom-set custom-set [] > #:property prop:constructor-style-printer > (list > (lambda (this) 'set) > (lambda (this) (set->list this))) > #:methods gen:set > ...) > > Where the constructor-style-printer could look for the > `prop:constructor-style-printer` property and use it to get the constructor > and the sub-expressions? I don't think that it works to require something for all future structs. Robby -- 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.