The import syntax could be simplified and made both more aesthetic and memorable by getting rid of from and nil
The two concepts involved:
Here's the syntax for what I think is the cleanest solution. I added the keywords open and include, and I got rid of from and nil:
import <module> [ [as <alias>] | open ] [ <include|exclude> N1,.. ]
The first part is where we're importing from. The second part is where we import to (if not specified, module name is used as the namespace for convenience). The third part is what we're importing (if not specified, everything is imported).
Alternatively, include could be renamed to only
Examples:
import library
import library include my_proc
import library exclude my_proc2
import library as lib
import library as lib include my_proc
import library as lib exclude my_proc2
import library open
import library open exclude my_proc2
import library open include my_proc
Long example with alignment:
import
net
asyncio as ad
base64 as b64 exclude encode
strutils open
os include sleep
Note: The default in all languages, even when a new namespace is specified(!)
In what languages? In Pascal symbols are imported in the current namespace.
Note: Is it ever a good idea to import into the current namespace?
Module names or aliases as namespaces arre needed for disambiguation, and nobody likes typing, so when no there's ambiguity, shorter syntax (using current namespace) is better. And Nim uses simultaneously current namespace and module name / alias, so one can just import a module and try using its symbols, and only when the compiler complains of ambiguity - add the namespace. So open should be the default, and the opposite - explicitly specified.