[m-rev.] for review: type_class_transformation.html
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Feb 27 14:03:16 AEDT 2004
For review by Fergus.
Zoltan.
compiler/notes/type_class_transformation.html:
Undo Fergus's recent addition of a request for a pointer to the
documentation of the proposed replacement for base_typeclass_infos,
since that pointer already exists a few lines above.
Document the mechanisms we use or should use for detecting duplicate
instance declarations.
cvs diff: Diffing .
Index: type_class_transformation.html
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/notes/type_class_transformation.html,v
retrieving revision 1.4
diff -u -b -r1.4 type_class_transformation.html
--- type_class_transformation.html 26 Feb 2004 02:23:31 -0000 1.4
+++ type_class_transformation.html 27 Feb 2004 02:59:59 -0000
@@ -30,10 +30,6 @@
The dictionary contains pointers to each of the class methods.
<p>
-XXX This documentation is not complete RE the current/future situation;
-we should add pointer to documentation for typeclass_decl etc.
-and/or replace this file.
-
Representation of a typeclass_info:
The typeclass_info is represented in two parts (the typeclass_info
itself, and a base_typeclass_info), in a similar fashion to the
@@ -211,6 +207,39 @@
r(TypeClassInfoT4, <type_info for int>, X, 0).
</pre>
<p>
+
+<H3> Detecting duplicate instance declarations </H3>
+
+We would like to catch duplicate instance declarations
+(those that declare the same vector of possibly unground types
+to be members of the same typeclass)
+as early as possible.
+Since duplicate declarations can occur in different modules,
+the earliest practical time is link time.
+We would therefore like to generate a name for the global variable
+that holds the base_typeclass_info of an instance declaration
+that depends only on the identity of the typeclass
+and on the instance declaration's vector of argument types.
+
+For the C backends, this is what we actually do.
+As a result, duplicate instance declarations will result in a link error
+for a multiply defined symbol.
+Note that the names of the global variables
+do in fact have module names in them,
+but they are the names of the modules that declare the type class
+and that declare the type constructors occuring in the argument types.
+The name of the module that contains the instance declaration
+need not be among these names.
+
+For the IL and Java backends, the data structures we generate
+must all be module qualified with the name of the module which generates them.
+If two modules contain duplicate instance declarations,
+we cannot catch that fact at link time.
+We could catch them at runtime,
+by having each module register its base_typeclass_infos
+at module initialization time,
+and detecting duplicate registrations.
+However, we currently have no such mechanism in place.
<hr>
<!-------------------------->
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list