[m-dev.] for review: type specialization [1]
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Feb 21 05:05:52 AEDT 1999
On 17-Feb-1999, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> Index: compiler/make_hlds.m
> +add_pragma_type_spec(Pragma, SymName, SpecName, Arity, MaybePredOrFunc,
> + MaybeModes, SpecSubst, VarSet, Context, Module0, Module) -->
> + { module_info_get_predicate_table(Module0, Preds) },
> + (
> + { MaybePredOrFunc = yes(PredOrFunc) ->
> + predicate_table_search_pf_sym_arity(Preds,
> + PredOrFunc, SymName, Arity, PredIds)
> + ;
> + predicate_table_search_sym_arity(Preds,
> + SymName, Arity, PredIds)
> + }
> + ->
> + ( { PredIds = [PredId] } ->
> + add_pragma_type_spec_2(Pragma, SymName, SpecName,
> + Arity, SpecSubst, MaybeModes, VarSet, Context,
> + PredId, Module0, Module)
> + ;
> + % XXX we should allow the programmer to specify
> + % predicate or function to avoid this problem.
> + % It's difficult to just specialize all matching names
> + % because we've only included a single specialized
> + % name in the interface file.
> + { Module = Module0 },
> + io__set_exit_status(1),
> + prog_out__write_context(Context),
> + io__write_string(
> + "Error: `pragma type_spec' declaration matches\n"),
> + prog_out__write_context(Context),
> + io__write_string(
> + " multiple predicates or functions.\n")
> + )
That error condition should be documented in the language
reference manual.
> + ;
> + undefined_pred_or_func_error(SymName, Arity, Context,
> + "pragma type_spec declaration"),
That should perhaps be "`pragma type_spec' declaration".
Please make sure that it is consistent with whatever format
we use for similar messages for other pragma declarations.
...
> + % Even if we aren't doing type specialization, we need
> + % to create the interface procedures for local predicates
> + % to check the type-class correctness of the requested
> + % specializations.
The type-class correctness condition referred to here
should be documented in the language reference manual.
> +report_pragma_type_spec(PredInfo0, Context) -->
> + { pred_info_module(PredInfo0, Module) },
> + { pred_info_name(PredInfo0, Name) },
> + { pred_info_arity(PredInfo0, Arity) },
> + { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) },
> + prog_out__write_context(Context),
> + io__write_string("In `pragma type_spec(...)' declaration for "),
Perhaps s/(...)//
Actually I'm not particularly dogmatic about whether the
`(...)' should be there, but please make sure it is
consistent with the messages for other pragmas.
> +handle_pragma_type_spec_modes(SymName, Arity, Context, MaybeModes, ProcIds,
> + Procs0, Procs, ModesOk, ModuleInfo0, ModuleInfo) -->
A brief comment explaining what that predicate does would be helpful.
...
> + undefined_mode_error(SymName, Arity, Context,
> + "`:- pragma type_spec(...)' declaration"),
Again, please make sure that the use of `:-' and `(...)' here
are consistent with what is done for other pragmas.
Apart from those things, the rest of part [1] looks fine.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh> | but source code lives forever"
PGP: finger fjh at 128.250.37.3 | -- leaked Microsoft memo.
More information about the developers
mailing list