Re: [sv-bc] Ballot issue 11/Mantis 2665 - are compilation unit imports re-exported

From: Greg Jaxon <Greg.Jaxon_at_.....>
Date: Mon Apr 27 2009 - 10:26:10 PDT
Gordon Vreugdenhil wrote:
The ballot issue uses the example:

    package P;
       integer r;
    endpackage

    import P::*; // P is imported in compilation unit scope

    module top;
       integer s = $unit::r; // ‘r’ refers to the declaration in package P
                             // imported in compilation unit scope
    endmodule
  
I agree with Gordon that this question is based on misconceptions.
In addition to all the true things Gordon said I'd add these points
  1. Like pkg::name, $unit::name is an "extraction", not an import.
  2. Extractions do not declare the extracted name in the receiving scope.
  3. Extractions cannot "trigger" wildcard import into the package (or $unit) scope.
Both comments are utterly incorrect.
The import statement added no names to the $unit scope, only wildcard import candidates.
The $unit::r extraction is an error, because nothing has yet caused an import of r into $unit.
Drop the $unit:: from that reference and it will trigger the wildcard import of r into $unit, which could
then satisfy subsequent references via $unit::

The question is (essentially) whether imports into the compilation
unit are implicitly re-exported.

This question is directly related to Issue 10/Mantis 2664.  See
me comments on that item first.

I don't think that this is the correct view at all.  The compilation
unit is simply a lexical scope so all identifiers visible in that
scope are lexically resolved in a normal manner.  The $unit::r
is simply a naming mechanism to get at the scope (since it is
otherwise anonymous).  The "::" syntax here is a bit misleading
as it reinforces the view of $unit as a package (which it is not).
It might have been an idea to use "." rather than "::" but that
would have suggested an even worse view -- that such references
are hierarchical (and might allow arbitrary forward references).
That is clearly not the intent; 3.12.1 has:
    The use of an explicit $unit:: prefix only provides for
    name disambiguation and does not add the ability to refer
    to later compilation unit items.


Gord.

--
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

  

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean. Received on Mon Apr 27 11:16:47 2009

This archive was generated by hypermail 2.1.8 : Mon Apr 27 2009 - 11:17:45 PDT