Re: [sv-bc] visiblity of imported package function

From: Greg Jaxon <Greg.Jaxon_at_.....>
Date: Fri Feb 29 2008 - 09:08:38 PST
Sarani,
   The discussions that Brad cited arose from the fact that implementations
accidentally took opposite views of how imported names should/shouldn't
be re-exported.  If they /are/ re-exported, your module can refer to func1() without
the scope operator.  If they /are not/ re-exported, then func1() can be called
inside my_pack, but the only way to call it inside the module would be to
refer to bottom::func1().

> So is the function now declared in my_pack scope?

   Yes - with a footnote: the original LRM authors apparently imagined
a property of declared names that they forgot to write about which is
the /visibility/ of this declared name to importers of my_pack.

   The resolution of this issue led to the design of explicit re-export syntax,
that (in my personal opinion) is clunky and un-intuitive.   I would have
been happy with achieving both import and re-export in a single declaration
" export bottom :: * ; ".   I don't understand what goal is served by having
this syntax be an error unless you've preceded it with " import bottom :: * ;".

   If there is a reason to have different names be in/visible, it should arise
from the user's need to control access to his data abstractions.  Visibility
hasn't got anything to do with the source of the definition for the name.

   Instead of adding an "export" declaration, a far better plan would
have been to add a "private"  declaration, or better yet a modifier to
any existing declarations.  Something like:

   import private bottom::*;

This way when the authors of bottom remove func1(), my_pack's author
can add it to his package without adding it to his exported names by
declaring

  function private int func1;
    func1 = 1;
  endfunction


Greg


Sarani Roy wrote:
> Hi,
> 
> I have doubts about importing a package through wild card import :
> package bottom;
> function int func1;
>  func1 = 1;
> endfunction
> endpackage
> 
> package my_pack;
>  import bottom::*;
>  int int1;
>  int int2 = func1();
> endpackage
> 
> module package_scope4(input int in1,output int out1);
>  import my_pack::*;
>  always@(in1)
>   begin
>     out1 = my_pack::func1();
>  end
> endmodule
> 
> In the example above, I have declared a bottom package which defines a
> function.
> This package is again imported into another package my_pack.
> The function is now used inside this package .
> 
> So is the function now declared in my_pack scope?
> 
> Also can I refer to this function through scope resolution operator
> inside the module?
> 
> If yes then is scope resolution operator necessary for referencing the
> function as wildcard import
> has been used and also there is no name conflict in the local scope.
> 
> Thanks,
> Sarani
> 
> 
> 
> 
> 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Feb 29 09:09:43 2008

This archive was generated by hypermail 2.1.8 : Fri Feb 29 2008 - 09:10:12 PST