[m-dev.] for review: rewrite of termination analysis (part 1)
Tyson Dowd
trd at cs.mu.oz.au
Mon Dec 22 20:02:10 AEDT 1997
On 22-Dec-1997, Zoltan Somogyi <zs at cs.mu.oz.au> wrote:
>
> This part has the new and substandtially rewritten files.
>
> Fergus, please review this. (I have already taken your very partial review
> into consideration, except for one point. There is no need at least at the
> moment to try to print the names of compiler generated predicates specially,
> since no error messages from termination analysis will complain about to them.)
>
> Zoltan.
>
> %-----------------------------------------------------------------------------%
> % Copyright (C) 1997 The University of Melbourne.
> % This file may only be copied under the terms of the GNU General
> % Public License - see the file COPYING in the Mercury distribution.
> %-----------------------------------------------------------------------------%
> %
> % error_util.m
> % Main author: zs.
> %
> % This module contains code that can be helpful in the formatting of
> % error messages.
> %
> %-----------------------------------------------------------------------------%
>
> :- module error_util.
>
> :- interface.
>
> :- import_module io, list, term, string, int.
>
> % Given a context, a starting indentation level and a list of words,
> % print an error message that looks like this:
> %
> % module.m:10: first line of error message blah blah blah
> % module.m:10: second line of error message blah blah blah
> % module.m:10: third line of error message blah blah blah
> %
> % The words will be packed into lines as tightly as possible,
> % with spaces between each pair of words, subject to the constraints
> % that every line starts with a context, followed by Indent+1 spaces
> % on the first line and Indent+3 spaces on later lines, and that every
> % line contains at most 79 characters (unless a long single word
> % forces the line over this limit).
>
> :- pred write_error_pieces(term__context::in, int::in, list(string)::in,
> io__state::di, io__state::uo) is det.
I think this is too low-level an interface. To use this, you need
to do
write_error_pieces(TC, 0, ["An", "error", "message", "that",
"is", "a", "real", "pain", "to", "write", "and", "more",
"difficult", "to", "read", "when", "in", "code"]).
Writing this doesn't make me feel like I'm using an advanced high-level
language ;-)
There should also be an interface that allows a string to be given, that
will be made into a list of strings at any whitespace. And perhaps
an interface that will take a list of such strings.
I'd certainly prefer
write_error_pieces(TC, 0, [
freeform("An error message that is a"), piece("real pain"),
freeform("to write and"), piece("more difficult"),
freeform("to read when in code.")].
So you can specify what is free-form text and what things need to remain in
one piece. But it can remain a wish-list item for now, since this nicer
interface can easily be added at a later stage.
--
Tyson Dowd # If I'm unusually agressive in this email, it's
# probably because USENET has been down here for
trd at cs.mu.oz.au # over a week, and I'm missing my usual dosage
http://www.cs.mu.oz.au/~trd # of flamewars. My apologies in advance.
More information about the developers
mailing list