Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
language:namespaces [2020/05/01 16:48]
rajit [Importing namespaces]
language:namespaces [2022/05/13 08:46] (current)
rajit
Line 12: Line 12:
 A namespace is created by using the ''namespace'' construct. A namespace is created by using the ''namespace'' construct.
  
-<code>+<code act>
 namespace lib { namespace lib {
 ... ...
Line 38: Line 38:
 namespaces is shown below. namespaces is shown below.
  
-<code>+<code act>
 namespace datapath { namespace datapath {
     export defproc bus_interface(...) { ... }     export defproc bus_interface(...) { ... }
Line 64: Line 64:
 the entire namespace ''adder'' can be exported as follows: the entire namespace ''adder'' can be exported as follows:
  
-<code>+<code act>
 namespace datapath { namespace datapath {
     export defproc bus_interface(...) { ... }     export defproc bus_interface(...) { ... }
Line 93: Line 93:
 The basic form of import statement is shown below: The basic form of import statement is shown below:
  
-<code>+<code act>
 import "channel.act"; import "channel.act";
 ... ...
Line 111: Line 111:
 hierarchy. The import statement hierarchy. The import statement
  
-<code>+<code act>
 import processor::lib; import processor::lib;
 </code> </code>
Line 117: Line 117:
 is equivalent to the following: is equivalent to the following:
  
-<code>+<code act>
 import "processor/lib/_all_.act"; import "processor/lib/_all_.act";
 </code> </code>
Line 123: Line 123:
 It assumes that the file ''_all_.act'' in the directory It assumes that the file ''_all_.act'' in the directory
 ''processor/lib'' contains all the definitions corresponding to the ''processor/lib'' contains all the definitions corresponding to the
-''processor::lib'' namespace.+''processor::lib'' namespace. More precisely, an import statement 
 + 
 +<code act> 
 +import foo; 
 +</code> 
 + 
 +would do the following: 
 +  * Look for ''foo/_all_.act'' using the search paths specified earlier; 
 +  * If unsuccessful, then look for ''foo.act'' 
 +  * If unsuccessful, report an error 
 + 
 +After the import, the specified namespace is checked to see if it exists. If not, an error will be reported. 
  
 ===== Opening namespaces ===== ===== Opening namespaces =====
Line 131: Line 143:
 To resolve this issue, ACT provides a way to rename a namespace that has been imported. To resolve this issue, ACT provides a way to rename a namespace that has been imported.
  
-<code>+<code act>
 import "lib1.act"; import "lib1.act";
 open lib -> lib1; open lib -> lib1;
Line 149: Line 161:
 because not all types might be exported! In this case we can say: because not all types might be exported! In this case we can say:
  
-<code>+<code act>
 import "lib.act"; import "lib.act";
 open processor::lib; open processor::lib;