[Ocaml-pxp-users] pretty printer proposal/uninstall correction

Gerd Stolpmann info at gerd-stolpmann.de
Tue Aug 30 03:32:53 PDT 2005


Am Freitag, den 26.08.2005, 10:14 -0700 schrieb Victor Seletskiy:
> here proposal of pretty printer (which change write method to more
> readable format)
> in addition there is slight change to config file in order to remove
> one library, which left after uninstall was run. this in turn will
> prevent following installation

Well, I don't like this pretty printer patch. There is too much code
duplication. We already have two printing methods, [write] and
[display], which differ in their handling of namespaces. If we start to
include variants of these the number of printing methods will soon
explode.

But I am not against pretty printing in general. However, I think the
core of the formatter should be kept outside of the document containers
(Pxp_document and Pxp_dtd), and it should be possible to select the
formatter from several implementations.

What I have in mind is that [write] and [display] no longer print
directly (using a printing function), but only generate print particles
that are sent to the formatter. This could be something simple like

type print_particle = string * print_tag

and print_tag = [ `Start_tag_left_angle
                | `Start_tag_name
                | `Start_tag_whitespace
                | `Start_tag_att_name
                | `Start_tag_att_is
                | `Start_tag_att_value
                | `Start_tag_right_angle
                ...
                ]

i.e. the particles are tagged strings. A trivial formatter could simply
ignore the tags and concatenate the strings. More sophisticated
formatters have enough information to insert spaces and linebreaks where
needed to get nice output. It would even be possible to generate
colourised output.

Anyway, thank you for starting the discussion.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd at gerd-stolpmann.de          http://www.gerd-stolpmann.de
Telefon: 06151/153855                  Telefax: 06151/997714
------------------------------------------------------------




More information about the Ocaml-pxp-users mailing list