[m-rev.] for review: atoms in the debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jan 2 16:51:53 AEDT 2002


On 31-Dec-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Give the debugger the ability to print atoms.

As a matter of terminology, I don't think we should use the term "atom";
instead we should use "closure" or perhaps "higher-order term",
for consistency with the Mercury language reference manual.
The term "atom" is a misnomer (they're decomposable, not atomic),
and is confusing for people used to Prolog or Lisp terminology.

This applies to the NEWS file, the new command names, and (although
it's not very important in this case) to the log message

> browser/browser_info.m:
> 	Define a new type, browser_term, which represents either a plain term,
> 	or a "synthetic term", which is a string (predicate or function name),
> 	a list of argument values, and an indication of whether the synthetic
> 	term is a predicate atom (i.e. of the form p(a1, ..., an)) or a
> 	function atom (i.e. of the form f(a1, ..., an-1) = an).

Why do these two need to be handled differently?

Are plain terms allowed to have higher-order types?
Are synthetic terms allowed to be first-order,
i.e. can they have a data constructor rather than a function name?

> +++ browser/browse.m	2001/12/30 18:01:19
> @@ -20,8 +20,8 @@
>  
> +:- pred browse__browse_synthetic(string::in, list(univ)::in, bool::in,
> +	io__input_stream::in, io__output_stream::in, maybe(list(dir))::out,
> +	browser_persistent_state::in, browser_persistent_state::out,
> +	io__state::di, io__state::uo) is det.
> +
> +:- pred browse__browse_format_synthetic(string::in, list(univ)::in, bool::in,
> +	io__input_stream::in, io__output_stream::in, portray_format::in,
> +	browser_persistent_state::in, browser_persistent_state::out,
> +	io__state::di, io__state::uo) is det.
...
> +:- pred browse__print_synthetic(string::in, list(univ)::in, bool::in,
> +	io__output_stream::in, browse_caller_type::in,
> +	browser_persistent_state::in, io__state::di, io__state::uo) is det.
...
> +:- pred browse__print_format_synthetic(string::in, list(univ)::in, bool::in,
> +	io__output_stream::in, browse_caller_type::in, portray_format::in,
> +	browser_persistent_state::in, io__state::di, io__state::uo) is det.

There should be comments in the interface section here
explaining what these predicates do.

> +browser_term_size_left_from_max(BrowserTerm, MaxSize, RemainingSize) :-
> +	(
> +		BrowserTerm = plain_term(Univ),
> +		term_size_left_from_max(Univ, MaxSize, RemainingSize)
> +	;
> +		BrowserTerm = synthetic_term(Functor, Args, IsFunc),
> +		string__length(Functor, FunctorSize),
> +		list__length(Args, Arity),
> +		(
> +			IsFunc = yes,
> +			PrincipalSize = FunctorSize + 1 + Arity * 2
> +		;
> +			IsFunc = no,
> +			PrincipalSize = FunctorSize + Arity * 2

Comments here explaining the rationale for these magic formulae would help.

> +			brack_args(PredArgStrs, BrackPredArgsStr),

It took me a long time to figure out what "brack" stood for here.
So I suggest that you spell these out in greater length,
e.g. "bracket_args" instead of "brack_args".
and BracketedPredArgsStr instead of BrackPredArgsStr.

> +browser_term_compress(BrowserTerm, Str) :-
> +	functor_browser_term(BrowserTerm, Functor, Arity, IsFunc),
>  	( Arity = 0 ->
>  		Str = Functor
>  	;
> +		(
> +			IsFunc = yes,
> +			int_to_string(Arity - 1, ArityS),
> +			append_list([Functor, "/", ArityS, "+1"], Str)

Hmmm, you're abbreviating function terms as `foo/N+1',
(e.g. `std_util:yes/1+1').

The usual abbreviation would be without the `+1' at the end.

[... to be continued ...]

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list