[m-dev.] for review: allow separate mode decls for zero arity preds
Fergus Henderson
fjh at cs.mu.OZ.AU
Sat Sep 4 01:40:56 AEST 1999
On 30-Aug-1999, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
>
> Allow separate mode declarations for predicates with no arguments
> (previously they were considered to be duplicate mode declarations).
> This avoids the need to special case such predicates when writing
> out declarations for inter-module optimization.
>
> If there is no mode declaration and the `:- pred' declaration does
> not include the determinism, a default mode `:- mode foo.' is added.
What about the case where there is no mode declaration and no pred
declaration either?
In that case, your code adds a default mode.
This is a change from the previous behaviour, and I'm not convinced
that it is the right thing to do. It also happens to break
extras/clpr/samples/tests.m.
In cases where there is no mode declaration and no pred declaration,
the default mode will be inferred if it is used. But if it is not used,
I do not think there is any complelling reason why it should be added.
Therefore I propose the following fix.
----------
Estimated hours taken: 0.75
compiler/make_hlds.m:
Don't add a default mode for predicates with zero arity
and no pred or mode declaration. The rationale is that
there's no compelling reason to add a default mode, since
the mode will be inferred anyway, if it is used,
and adding a default mode breaks some existing code,
e.g. extras/clpr/samples/tests.m, which assumes that
a predicate that is not called and which has zero arity and
no pred or mode declaration need not be mode-correct.
Workspace: /usr/hg/public/test_mercury/test_dirs/hg/mercury
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/make_hlds.m,v
retrieving revision 1.301
diff -u -r1.301 make_hlds.m
--- compiler/make_hlds.m 1999/08/31 05:25:33 1.301
+++ compiler/make_hlds.m 1999/09/03 15:22:53
@@ -2943,13 +2943,13 @@
{ ModuleInfo = ModuleInfo0 },
{ Info = Info0 }
;
- { pred_info_clauses_info(PredInfo1, Clauses0) },
- { pred_info_typevarset(PredInfo1, TVarSet0) },
- { maybe_add_default_func_mode(PredInfo1, PredInfo2a, _) },
- maybe_add_default_zero_arity_pred_mode(PredInfo2a,
- PredInfo2, _),
- { pred_info_procedures(PredInfo2, Procs) },
- { map__keys(Procs, ModeIds) },
+ {
+ pred_info_clauses_info(PredInfo1, Clauses0),
+ pred_info_typevarset(PredInfo1, TVarSet0),
+ maybe_add_default_func_mode(PredInfo1, PredInfo2, _),
+ pred_info_procedures(PredInfo2, Procs),
+ map__keys(Procs, ModeIds)
+ },
clauses_info_add_clause(Clauses0, PredId, ModeIds,
ClauseVarSet, TVarSet0, Args, Body, Context,
IsAssertion, Goal,
--
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