[m-rev.] For revew: a new, improved pretty printer
Ralph Becket
rafe at csse.unimelb.edu.au
Wed Aug 1 17:36:00 AEST 2007
I've adopted all your suggestions except for the module qualification
issue which I think has revealed a bug in that part of the compiler
(type_ctor_module_name does not seem to return a consistent result).
Here's an interdiff:
diff -u library/pretty_printer.m library/pretty_printer.m
--- library/pretty_printer.m 1 Aug 2007 00:33:23 -0000
+++ library/pretty_printer.m 1 Aug 2007 07:28:08 -0000
@@ -1,8 +1,14 @@
%-----------------------------------------------------------------------------%
-% pretty_printer.m
-% Ralph Becket <rafe at csse.unimelb.edu.au>
-% Fri Jun 1 14:49:30 EST 2007
-% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+% vim: ts=4 sw=4 expandtab tw=0 wm=0 ft=mercury
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2007 The University of Melbourne
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%-----------------------------------------------------------------------------%
+%
+% File: pretty_printer.m
+% Main author: rafe
+% Stability: medium
%
% This module defines the doc type and a pretty printer for formatting
% doc lists.
@@ -58,7 +64,7 @@
% group does not fit on the current
% line.
; open_group % Open a new group (groups control
- % how nls are handled).
+ % how newlines are handled).
; close_group % Close a group.
; indent(string) % Append a string to indentation.
; outdent % Remove the last indentation string.
@@ -156,18 +162,20 @@
<= stream.writer(Stream, string, State).
% Convenience predicates. A user-configurable set of type-specific
- % pretty-printers and formatting parameters are attached to the IO state.
- % The io state-specific format predicate below uses this settings.
+ % pretty-printers and formatting parameters are attached to the I/O state.
+ % The I/O state-specific format predicate below uses this settings.
%
:- type pp_params
---> pp_params(
- pp_line_width :: int,
- pp_max_lines :: int,
- pp_limit :: pp_limit
+ pp_line_width :: int, % Line width in characters.
+ pp_max_lines :: int, % Max lines to output.
+ pp_limit :: pp_limit % Max term formatting depth.
).
% The default pp_map may also be updated by initialisation goals in various
% modules.
+ % These defaults are thread local (i.e., changes made by one thread to
+ % the default pp_map will not be visible in another thread).
%
:- pred get_default_pp_map(pp_map::out, io::di, io::uo) is det.
:- pred set_default_pp_map(pp_map::in, io::di, io::uo) is det.
@@ -175,13 +183,15 @@
io::di, io::uo) is det.
% The initial default pp_params are pp_params(78, 100, triangular(100)).
+ % These defaults are thread local (i.e., changes made by one thread to
+ % the default pp_params will not be visible in another thread).
%
:- pred get_default_pp_params(pp_params::out, io::di, io::uo) is det.
:- pred set_default_pp_params(pp_params::in, io::di, io::uo) is det.
% format(Docs, !IO)
- % format(Stream, Docs, !IO)
- % Format Docs to io.stdout_stream or Stream respectively, using
+ % format(FileStream, Docs, !IO)
+ % Format Docs to io.stdout_stream or FileStream respectively, using
% the default pp_map and pp_params.
%
:- pred format(docs::in, io::di, io::uo) is det.
@@ -743,10 +753,10 @@
% Convenience predicates.
:- mutable(io_pp_map, pp_map, new_pp_map, ground,
- [attach_to_io_state, untrailed]).
+ [attach_to_io_state, untrailed, thread_local]).
:- mutable(io_pp_params, pp_params, pp_params(78, 100, triangular(100)),
- ground, [attach_to_io_state, untrailed]).
+ ground, [attach_to_io_state, untrailed, thread_local]).
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list