[m-dev.] types defined outside Mercury

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Feb 4 18:17:17 AEDT 2000


As a prelude to a redesign of the current system for using RTTI info
(which actually wasnn't really designed, it just grew), I am breaking
up std_util.m into three components: a part defining univ (univ.m, <300
lines), a part for functor, arg and their cousins (reflection.m, almost
2000 lines), and the rest (std_util.m, about 650 lines).

This requires moving the types univ, type_info and type_ctor_info
from std_util.m to the new modules. However, this is not currently
possible, because (a) the compiler insists on generating type_ctor_infos
and their components for all types it knows about, and (b) since these
types are defined outside Mercury, it does not know what to put into
the structures it insists on generating.

This is a general problem for all types defined outside Mercury.
At the moment, we don't solve the problem, we only work around it,
by keeping a list inside the compiler of types it should avoid generating
type_ctor_infos for. std_util:univ is on this list; univ:univ wasn't.
This list is in type_util.m, in predicate type_id_is_hand_defined.

At the moment the language reference manual says: "The implementation section
of a module must have give the definition of all the abstract types named in
the interface section of the module. Abstract types may be defined as either
discriminated union types or as equivalence types."

I propose that we change this, and add a third option, which is to allow
programs to say ":- type univ is external". This will be quite useful for
people who interface Mercury to C (no more declaring everything as equivalent
to c_pointer), and will make easier to work on HAL, as well as certain parts
of Mercury itself.

A corollary of this change would be that the compiler should enforce the rule
I quoted; at the moment, it doesn't. At the moment, it needs to allow types
such as univ to not be defined in Mercury, and the mechanism actually allows
any type, not just those listed in type_id_is_hand_defined, to omit the
actual definition.

Any opinions?

The log message and diff for the diff I committed are below.

Zoltan.

Prepare for the breakup of std_util.m.

cvs diff: Diffing .
Index: type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.76
diff -u -b -r1.76 type_util.m
--- type_util.m	2000/01/13 06:17:11	1.76
+++ type_util.m	2000/02/04 06:36:30
@@ -370,6 +370,8 @@
 type_id_is_hand_defined(qualified(unqualified("builtin"), "c_pointer") - 0).
 type_id_is_hand_defined(qualified(unqualified("std_util"), "univ") - 0).
 type_id_is_hand_defined(qualified(unqualified("std_util"), "type_info") - 0).
+type_id_is_hand_defined(qualified(unqualified("univ"), "univ") - 0).
+type_id_is_hand_defined(qualified(unqualified("reflection"), "type_info") - 0).
+type_id_is_hand_defined(qualified(unqualified("reflection"), "type_desc") - 0).
 type_id_is_hand_defined(qualified(unqualified("array"), "array") - 1).
 type_id_is_hand_defined(qualified(PrivateBuiltin, "type_info") - 1) :-
 	mercury_private_builtin_module(PrivateBuiltin).
cvs diff: Diffing notes
--------------------------------------------------------------------------
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