imports section
Closed this issue · 1 comments
Some suggestions on
https://developer.aleo.org/developer/language/imports
-
Starting right at the top, it would be good to describe what sorts of entities can be imported. It appears that any top-level definition from a file can be imported, as long as the file is in a reachable location, either under the
src
directory or under theimports
directory (wherever that is) according to a certain directory pattern. -
It would be good to be clear about what a "project" vs a "package" is throughout the docs, to be consistent in the nomenclature. It would be good to define here what a
package
is. -
The first section,
Local
:Import from a local file in the same package src/ directory by its file name.
This sentence is hard to parse and should be reworded to be clearer. Maybe:Import from a local file in the src/ directory of the current package.
-
Also in
Local
, I suggest making this initial example simpler by importing a single name, not multiple names. There is a later section forImport Multiple
. -
2nd section,
Foreign
:Import from a foreign package in the imports/ directory using its [package] name.
Is theimports/
directory defined anywhere? There should be a link to where it is defined. It is not clear in this section whether there is a config file somewhere that defines where it is, or whether it is supposed to be a sibling of thesrc
directory (but that would not be very "foreign"). -
Combined 1st section and 2nd section. If we simplify the 1st section so it is only importing the circuit Bar, then that would be the exact same syntax as the 2nd section:
import bar.Bar;
What if both filessrc/bar.leo
andimports/bar/src/lib.leo
exist and both have a circuitBar
in them. WhichBar
would be imported? What ifBar
is only in one or only in the other, wouldBar
be found in both cases? -
In the 2nd section, there is a little pattern describing what a Foreign import looks like:
import [package].[name];
However, the other sections don't have little patterns describing what they look like. Also, can Foreign imports be renamed with theas
keyword? This pattern implies that there are no other syntaxes for foreign imports. -
3rd section,
Package Paths
. The first example seems to conflict with theForeign
example. TheForeign
example has alib
file name that is omitted from the import declaration's package path. But this example has nolib
file. Islib
handled specially and omitted? If so, this fact should be mentioned. -
The first three sections nicely show the imported definitions in one file and then the importing main.leo file. The last three sections,
Import Aliases
,Import Multiple
, andImport Star
could benefit from similar examples.