Revised diff for parallel conjunction
Fergus Henderson
fjh at cs.mu.oz.au
Mon Oct 27 18:53:16 AEDT 1997
Thomas Charles CONWAY <conway at cs.mu.oz.au> writes:
>+ ; par_conj(hlds_goals, store_map)
>+ % parallel conjunction
>+ % The store_map specifies the locations
>+ % in which live variables should be
>+ % stored at the start of the parallel
>+ % conjunction.
At the start? Are you sure that's correct?
>+ % instmap__unify(NonLocalVars, InstMapNonlocalvarPairss):
>+ % Unify the `InstMaps' in the list of pairs resulting
>+ % from different branches of a parallel conjunction and
>+ % update the instantiatedness of all the nonlocal variables.
>+ % The variable locking that is done when modechecking
>+ % the individual conjuncts ensures that variables have
>+ % at most one producer.
This is not ideal -- ideally it would be possible for
different parallel conjuncts to bind different parts of
a single variable.
That is sufficient for now, but it might be worth adding a comment
about this.
>+instmap__unify(NonLocals, InstMapList, ModeInfo0, ModeInfo) :-
...
>+ % having got the first instmapping, to use as
>+ % an accumulator, all instmap__unify_2 which
>+ % unifies each of the nonlocals from each instmap
>+ % with the corresponding inst in the accumulator.
s/all/call/ ?
>+ ; join_and_terminate(lval)
>+ % Signal that this thread of execution has finished in
>+ % the current parallel conjunction, then terminate it.
>+ % The synchronisation term specified by the
>+ % given lval. (See the documentation in par_conj_gen.m
>+ % and runtime/context.mod for further information about
>+ % synchronisation terms.)
s/specified/is specified/
>+ ; join_and_continue(lval, label)
>+ % Signal that this thread of execution has finished
>+ % in the current parallel conjunction, then branch to
>+ % the given label. The synchronisation
>+ % term specified by the given lval.
s/specified/is specified/
>+ ; mode_error_par_conj(merge_errors)
>+ % different arms of a parallel conj result in
>+ % mutually exclusive bindings
[...]
>+ ; mode_error_bind_var(var, inst, inst, lock_context)
> % attempt to bind a non-local variable inside
>+ % a negated context, or attempt to re-bind a variable
>+ % in a parallel conjunct
[...]
>+ ; mode_error_parallel_var(var, inst, inst)
>+ % attempt to bind a non-local variable that has already
>+ % been bound in another parallel conjunct.
I still don't understand the difference between these three possible
errors. Certainly the parallel conjunct case of mode_error_bind_var
seems identical to mode_error_parallel_var.
And what exactly do you mean by "mutually exclusive"?
>+ { LockContext = lambda_goal },
>+ prog_out__write_context(Context),
>+ io__write_string(
>+ " scope error: attempt to bind a nonlocal variable inside\n"),
>+ prog_out__write_context(Context),
>+ io__write_string(" a pred/lambda goal.\n")
I suggest you just say "lambda goal" rather than "pred/lambda goal".
>+++ modecheck_unify.m 1997/10/21 05:28:13
>@@ -381,10 +381,11 @@
> % lock the non-locals
> % (a lambda goal is not allowed to bind any of the non-local
> % variables, since it could get called more than once)
>+ % `negation' as the locked_var_context is a place holder.
That comment is obsolete.
>+:- pred modecheck_par_conj_list(list(hlds_goal), list(hlds_goal),
>+ set(var), list(pair(instmap, set(var))), mode_info, mode_info).
>+:- mode modecheck_par_conj_list(in, out, in, out,
>+ mode_info_di, mode_info_uo) is det.
>+
>+modecheck_par_conj_list([], [], _NonLocals, []) --> [].
>+modecheck_par_conj_list([Goal0|Goals0], [Goal|Goals], NonLocals,
>+ [InstMap - GoalNonLocals|InstMaps]) -->
>+ mode_info_dcg_get_instmap(InstMap0),
>+ { Goal0 = _ - GoalInfo },
>+ { goal_info_get_nonlocals(GoalInfo, GoalNonLocals) },
>+ mode_info_get_parallel_vars(PVars0),
>+ { set__init(Bound0) },
>+ mode_info_set_parallel_vars([NonLocals - Bound0|PVars0]),
>+
>+ modecheck_goal(Goal0, Goal),
>+ mode_info_get_parallel_vars(PVars1),
>+ (
>+ { PVars1 = [_ - Bound1|PVars2] },
>+ (
>+ { PVars2 = [OuterNonLocals - OuterBound0|PVars3] },
>+ { set__intersect(OuterNonLocals, Bound1, Bound) },
>+ { set__union(OuterBound0, Bound, OuterBound) },
>+ { PVars = [OuterNonLocals - OuterBound|PVars3] },
>+ mode_info_set_parallel_vars(PVars)
>+ ;
>+ { PVars2 = [] },
>+ mode_info_set_parallel_vars(PVars2)
>+ )
>+ ;
>+ { PVars1 = [] },
>+ { error("lost parallel vars") }
>+ ),
>+ mode_info_dcg_get_instmap(InstMap),
>+ mode_info_set_instmap(InstMap0),
>+ mode_info_lock_vars(Bound1, par_conj),
>+ modecheck_par_conj_list(Goals0, Goals, NonLocals, InstMaps),
>+ mode_info_unlock_vars(Bound1).
Some comments here would be helpful.
>-modecheck_set_var_inst(Var0, FinalInst, ModeInfo0, ModeInfo) :-
>+modecheck_set_var_inst(Var0, FinalInst, ModeInfo00, ModeInfo) :-
...
>+ (
>+ PVars0 = [],
>+ ModeInfo = ModeInfo3
>+ ;
>+ PVars0 = [NonLocals - Bound0|PVars1],
>+ ( set__member(Var0, NonLocals) ->
>+ set__insert(Bound0, Var0, Bound),
>+ PVars = [NonLocals - Bound|PVars1]
>+ ;
>+ PVars = PVars0
>+ ),
>+ mode_info_set_parallel_vars(PVars, ModeInfo3, ModeInfo)
> ).
A comment here would be helpful.
--
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