[m-dev.] Contribution: Pretty Printing Library
Ralph Becket
rbeck at microsoft.com
Wed Apr 12 21:55:17 AEST 2000
Okay, I've added a new constructor label/2 which acts like nest/2
except that indentation is now specified using a string rather than
number of spaces. In terms of compositional behaviour etc. it is
otherwise identical to nest/2.
examples.m contains a demonstration:
=== Arbitrary Objects with Depth Limiting ===
behold: two("three", 3, three(...), two(...))
behold: two("three", 3, three(...), two(...))
behold: two(
behold: "three",
behold: 3,
behold: three(...),
behold: two(...)
behold: )
Note that because labels are just like nests, the label string
only gets printed as part of the indentation after newlines, so
there's no guarantee that a label will be printed if its argument
doc fits on the line. Question: is this reasonable behaviour
(sorry, semantics)?
Something I should point out is that pprint.m depends upon some
library changes I just checked in, namely the addition of
func string__length/1 to string.m and func id/1 to std_util.m
Cheers,
Ralph
--
Ralph Becket | MSR Cambridge | rbeck at microsoft.com
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list