Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
language:namespaces [2022/05/13 08:46] rajit |
language:namespaces [2024/07/27 12:52] (current) rajit [Renaming namespaces] |
||
---|---|---|---|
Line 139: | Line 139: | ||
===== Opening namespaces ===== | ===== Opening namespaces ===== | ||
- | If there are two different files that define the same namespace (say defined in multiple projects), importing both the files may result in type conflicts. Consider a scenario where we have two '' | + | If a project has many different people working on it, it can be convenient |
- | + | to have each component/ | |
- | To resolve this issue, ACT provides a way to rename a namespace that has been imported. | + | |
- | + | ||
- | <code act> | + | |
- | import " | + | |
- | open lib -> lib1; | + | |
- | import " | + | |
- | open lib -> lib2; | + | |
- | </ | + | |
- | + | ||
- | In this example, the '' | + | |
- | has occured, there cannot be any naming conflicts. This version of '' | + | |
- | + | ||
- | A second issue is one that is more about convenience. Consider a | + | |
- | project that has many different people working on it, each in their | + | |
own namespace to avoid naming conflicts. This situation can result in | own namespace to avoid naming conflicts. This situation can result in | ||
very long type names. Plus it would be more bookkeeping to have to | very long type names. Plus it would be more bookkeeping to have to | ||
create a test environment for the types within, say, | create a test environment for the types within, say, | ||
'' | '' | ||
- | because not all types might be exported! | + | because not all types might be exported! |
+ | |||
+ | As a syntactic convenience, | ||
<code act> | <code act> | ||
Line 176: | Line 164: | ||
at the beginning of an ACT file. | at the beginning of an ACT file. | ||
+ | ===== Renaming namespaces ===== | ||
+ | |||
+ | |||
+ | If there are two different files that define the same namespace (say defined in multiple projects), importing both the files may result in type conflicts. Consider a scenario where we have two '' | ||
+ | |||
+ | To resolve this issue, ACT provides a way to rename a namespace that has been imported. | ||
+ | |||
+ | <code act> | ||
+ | import " | ||
+ | open lib -> lib1; | ||
+ | import " | ||
+ | open lib -> lib2; | ||
+ | </ | ||
+ | |||
+ | In this example, the '' | ||
+ | has occured, there cannot be any naming conflicts. This version of '' | ||
+ | |||
+ | Another renaming scenario that can be useful is to move a namespace into another one. | ||
+ | <code act> | ||
+ | import lib; | ||
+ | import lib => priv; | ||
+ | </ | ||
+ | The first import statement above loads in the '' |