[m-dev.] for review: contexts in tabled predicates
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Dec 20 21:20:53 AEDT 1999
On 20-Dec-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
>
> Add meaningful contexts to the goals inserted into predicates by tabling,
> for use by the debugger.
>
> compiler/trace.m:
> Pass the context of the procedure body through the code, and create
> new goals with this context.
>
> To make this simpler, switch to consistently using combined predmode
> definitions. In a couple of places, switch to a more reasonable
> argument ordering.
I think you mean compiler/table_gen.m, not compiler/trace.m.
> + % The goal_info_init/4 predicate in hlds_goal.m does almost everything
> + % tabling wants in initializing the goal_infos of the new goals it
> + % creates, but it does not fill in the context, which is therefore
> + % initialized to a dummy value. This means that when debugging is
> + % enabled, the call event and the internal events that record the
> + % working of tabling get no contexts recorded for them in the RTTI.
> +
> +:- pred init_goal_info(set(prog_var)::in, instmap_delta::in, determinism::in,
> + term__context::in, hlds_goal_info::out) is det.
> +
> +init_goal_info(NonLocals, InstMapDelta, Detism, Context, GoalInfo) :-
> + goal_info_init(NonLocals, InstMapDelta, Detism, GoalInfo0),
> + goal_info_set_context(GoalInfo0, Context, GoalInfo).
I think it would be slightly clearer to state that comment in a way
that more directly describes what the code does and why, e.g.
% The goal_info_init/4 predicate in hlds_goal.m does almost everything
% tabling wants in initializing the goal_infos of the new goals it
% creates, but it does not fill in the context. We need to use
% the predicate init_goal_info/5 (below) to fill in the context, so that
% when debugging is enabled, the call event and the internal events
% that record the working of tabling get the correct contexts recorded
% for them in the RTTI.
rather than describing what it used to do and why that didn't work.
> Index: tests/debugger/loopcheck.m
> ===================================================================
> RCS file: loopcheck.m
> diff -N loopcheck.m
> --- /dev/null Thu Mar 4 04:20:11 1999
> +++ loopcheck.m Mon Dec 20 17:56:25 1999
> @@ -0,0 +1,17 @@
> +% Regression test.
> +
> +% rotd-1999-10-29 got a software error when compiling this test.
That comment is appropriate for the test in tests/tabling,
but the purpose of this test case in tests/debugger is
different, and the comment should reflect that.
> +main --> { loop(10) }, io__write_string("Hello, world\n").
...
> +loop(X) :- loop(X).
If the aim of this test is to test that the compiler generates correct
contexts, it would be better to put more newlines in the code
so that the different parts get different contexts:
main -->
{ loop(10) },
io__write_string("Hello, world\n").
...
loop(X) :-
loop(X).
Apart from that, this change looks fine.
--
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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list