[m-dev.] for review: type class error messages

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Sep 22 17:27:05 AEST 1998


On 22-Sep-1998, David Glen JEFFERY <dgj at cs.mu.OZ.AU> wrote:
> Index: check_typeclass.m
> @@ -289,40 +299,69 @@
...
> -                InstanceNames = [_,_|_]
> +                InstanceNames = [_-I1,I2|Is]
>          ->

Please put whitespace around operators such as `-', `,', and `|'.

Also, can you think of better variable names than `I1' and `I2'?
These variables have different types.  Perhaps it would be better
to write

	(
                InstanceNames = [I1, I2 | Is]
	->
		I1 = _ - Something
	;

but with a better name instead of `Something'.

> +                Heading = [I1-[words("First definition appears here.")],
> +                        InstanceContext-[words(ErrorHeader)]],

Whitespace around the `-' ops, please.

>                  string__append_list([
> -                        "No implementation for type class method ",
> +                        "In instance declaration for ",
> +                        ClassNameString,
> +                        "(",
> +                        InstanceTypesString,
> +                        "), ",

That should be "):" rather than "),", I think.

> +                string__append_list([
> +                        "In instance declaration for ",
> +                        ClassNameString,
> +                        "(",
> +                        InstanceTypesString,
> +                        "), ",

Ditto.

> +                Errors = [Context-[words(NewError)]|Errors0],

Whitespace around `-' and `|' please.

mercury_to_mercury.m:
> +        % This code could be written in terms of mercury_constraint_to_string
> +        % and io__write_string , but for efficiency's sake it's probably not

s/ ,/,/

> +        % XXX this should probably be a little cleverer, like
> +        % mercury_output_term. 
> +mercury_type_to_string(VarSet, term__variable(Var), String) :-
> +        varset__lookup_name(VarSet, Var, String).
> +mercury_type_to_string(VarSet, term__functor(Functor, Args, _), String) :-
...
> +                error("mercury_type_to_string: atom expected for type")

Since this predicate is used for printing out error messages,
I'm a bit worried that a syntactically malformed program could
trigger this call to error/1.  How about handling the non-atom cases?

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list