Hi Mark! I am not sure I understand what you mean, but i suspect it is already solved, since for simple cases show will use display/write. So unless you try to do advanced formatting of circular lists it will do whatever display or write does. The same thing goes for custom printers. In fact, anything that isn't a regular procedure will be printed just as it does in guile. Due to formatters being procedures, it is currently not possible to distinguish between formatters and other lambdas, but wrapping a lambda in (written ...) works just as (write ...).
So unless you tell show to do something else, it will default do guile's standard way. (show #t (exact->inexact 1/7)) is the same as (display (exact->inexact 1/7)), however (show #t (with ((precision 2)) ...)) is not. I don't know what circular structures guile uses internally, but (show...)ing a circular list without any formatter is, like numbers, the same as whatever guile does. (show #t (circular-list 1 2 3)) displays the same as (display (circular-list 1 2 3)). Did I misunderstand your questions? -- Linus Björnstam On Wed, 12 Jun 2019, at 00:03, Mark H Weaver wrote: > Hi Linus, > > Linus Björnstam <[email protected]> writes: > > > I just ported the reference implementation of SRFI-159/166 (166 being > > the successor of 159) from the reference implementation in chibi > > scheme. The srfi document is here: > > https://srfi.schemers.org/srfi-166/srfi-166.html > > > > SRFI-166 is like (ice-9 format) on steroids, drenched in molasses. It > > can do a lot more than (ice-9 format), but about 3x slower. I haven't > > started trying to make it fast just yet, but there are some low > > hanging fruit (like speeding up simple cases). I will wait with > > optimization until the srfi is finalized (and also maybe hear with > > Alex what he has in mind before trying to half-ass it myself). > > > > Anyway, the repo is here: https://bitbucket.org/bjoli/guile-srfi-159 > > . I haven't ported the tests, but playing with it in guile and chibi > > scheme produces the same result. Tests are up, but I'm travelling > > without computer the next week, so there is no time. > > I would be in favor of integrating this into Guile at some point, > although first I would like to make a careful review of the > implementation to make sure that it integrates well with Guile's related > mechanisms, e.g. custom record printers, printer options, and print > states, and that it supports all Guile data types. In particular, I > remember finding it difficult to properly implement cycle detection > while supporting Guile's existing mechanisms. I'm not sure it can be > done without modifying Guile's built-in printer. > > I'll also want to take a close look at the numeric formatter, to make > sure that it achieves the same properties as our built-in printer, > e.g. that it prints inexacts with the minimal number of digits required > to ensure that the same number will be read back in (unless specifically > asked to limit the precision). > > Anyway, thanks very much for sharing this! > > Regards, > Mark >
