[m-rev.] diff: imports shadowed by other imports

Zoltan Somogyi zoltan.somogyi at runbox.com
Tue Aug 25 00:36:14 AEST 2015


I don't think a review is needed for this one, but if anyone wants to
do one, only the first few files mentioned in the log message are
interesting; the rest is just the deletion of LOTS of unneeded imports.

I did find an interesting language design question while working on this.
It is about a situation in which the interface of module A used a type
that is defined in module B.C, and therefore has to import module B.C
in the interface. Our current rules say that A has import module B as well,
because B.C is inaccessible without that import, but it does *not* say
that A has to import B in its *interface*; an import in the implementation
will do. We have examples of this in the compiler. Foreign.m imports
libs.globals in the interface, and libs in the implementation, while
compiler/goal_path.m imports mdbcomp.goal_path in the interface
and mdbcomp in the implementation.

I believe this is inconsistent.

Not requiring the ancestors of a module imported in the interface
to be also imported *in the interface* does have logic behind it, e.g.
requiring the move of the import of e.g. mdbcomp to the interface
of compiler/goal_path.m would cause unnecessary recompilations.
Therefore I am not advocating that. However, we *could* drop
the requirement for an import of the ancestors altogether. The
reference manual says only "It is an error to import a module
without importing all of its parent modules", but does not say *why*,
and I don't remember the reason. Does anyone else? And would
anyone object to dropping the requirement?  If not having such imports
turns out to break something, the compiler could add such imports
implicitly as needed.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.import_shadow
Type: application/octet-stream
Size: 6507 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20150825/0c4050c6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.import_shadow
Type: application/octet-stream
Size: 298673 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20150825/0c4050c6/attachment-0001.obj>


More information about the reviews mailing list