From owner-sc22wg5@dkuug.dk  Sat Jul 12 00:22:25 2003
Received: (from majordom@localhost)
	by dkuug.dk (8.12.8p1/8.9.2) id h6BMMPXb069715
	for sc22wg5-domo; Sat, 12 Jul 2003 00:22:25 +0200 (CEST)
	(envelope-from owner-sc22wg5@dkuug.dk)
X-Authentication-Warning: ptah.dkuug.dk: majordom set sender to owner-sc22wg5@dkuug.dk using -f
Received: from math.jpl.nasa.gov (math.jpl.nasa.gov [137.79.7.57])
	by dkuug.dk (8.12.8p1/8.9.2) with ESMTP id h6BMIgEc069700
	for <sc22wg5@dkuug.dk>; Sat, 12 Jul 2003 00:22:22 +0200 (CEST)
	(envelope-from vsnyder@math.jpl.nasa.gov)
Received: from math.jpl.nasa.gov (localhost.localdomain [127.0.0.1])
	by math.jpl.nasa.gov (8.12.8/8.12.8) with ESMTP id h6BIN0Jh029170
	for <sc22wg5@dkuug.dk>; Fri, 11 Jul 2003 11:23:00 -0700
Received: from math.jpl.nasa.gov (vsnyder@localhost)
	by math.jpl.nasa.gov (8.12.8/8.12.8/Submit) with ESMTP id h6BIN0Xk029166
	for <sc22wg5@dkuug.dk>; Fri, 11 Jul 2003 11:23:00 -0700
Message-Id: <200307111823.h6BIN0Xk029166@math.jpl.nasa.gov>
X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4
Reply-to: Van.Snyder@jpl.nasa.gov
From: Van.Snyder@jpl.nasa.gov
To: sc22wg5@dkuug.dk
Subject: Consequences of current design of Modules TR
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Date: Fri, 11 Jul 2003 11:23:00 -0700
Sender: owner-sc22wg5@dkuug.dk
Precedence: bulk


The current draft of the Modules TR specifies that a submodule accesses
its parent module or submodule by host association.  There are some
"interesting" consequences of this.  These are all obvious once you
think them through, but I want you to be aware of them before you try
to choose whether a child submodule ought to access its parent by host
association or the new form that Lawrie proposes.

Suppose you have a module M with a child submodule C and a grandchild G.

Suppose in M you declare a separate interface for a module procedure P.
Suppose in C you declare another separate interface for a module procedure P.
Suppose in G you define a separate module procedure P.

The procedure P in G is related to the interface in C, not the one in M.
This is the way host association works, and the TR does not propose to
change it.  If another module accesses the interface for P from M, it
can't invoke P or use it for a target or actual argument, because there's
no corresponding procedure.  Hopefully, your linker will gripe.  Remember,
the name for P that the linker sees is almost surely not P (or p or p_).
It should be mangled with C (not M!) because that's where it's interface
is declared.  But C is not accessible by use association.  Any scoping
unit that does "use M, only: P" is going to get a P mangled with M.

Now suppose M has another child submodule C2, and you define a separate
module procedure P there.  Then that P's name would be mangled with
M (not C2!), and "use M, only P" would access that P.

Now suppose C has another submodule G2, in which there is a reference to P.
This refers to the P mangled with C, which body is in G, not the P mangled
with M, which body is in C2.

This may be exactly what you want to happen, but you need to be aware of it,
and use it carefully.  It's no different from an internal procedure having
an interface body for a dummy procedure that's the same name as an interface
body for an external procedure declared in its host procedure.

Start over.

Suppose in M you declare a separate interface for a module procedure P.
Suppose in C you declare an interface for an external procedure, also named P.
Suppose in G you define a separate module procedure P.

The definition of P in G is illegal.  It cannot access a separate interface
declaration of the same name by host association.  The interface of the same
name that it accesses by host association is not a separate interface.

This is the way host association works.  We all know how host association
works.  None of this should be a surprise, once you think it through.

If we adopt Lawrie's proposal for a new kind of association, and allow to
redeclare anything that's accessed from a parent by that kind of association,
we should require procedure interfaces to have identical characteristics
and identical dummy argument names.  Otherwise, you could get the kind of
strangeness noticed by Michael Ingrassia yesterday (or was it Wednesday?).

-- 
Van Snyder                    |  What fraction of Americans believe 
Van.Snyder@jpl.nasa.gov       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.


