Where is that documented to work?
it should be (IMO) based on orthogonality of features:
import bar/foo #ok
import ./foo #ok: foo is relative to ./
import ./foo/[bar1, bar2] #ok
import bar/[foo] #ok
import ./[foo] # error
import ./[bar1, bar2] # error
here's an example where it's useful to have:
in compiler/nim.nim:
import
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
extccomp, strutils, os, osproc, platform, main, parseopt,
nodejs, scriptconfig, idents, modulegraphs, lineinfos
it's not clear which of these are in ./ (ie, compiler) vs std/ (eg strutils)
eg, once https://github.com/nim-lang/Nim/pull/8614 (Nim now allows modules with same name in a package) is implemented, keeping that ambiguitiy is not good, and following code is better (IMO):
import
./[commands, lexer, condsyms, options, ... ]
std/[strutils, os, osproc, ...]
"." / [foo, bar] which works.@Araq
./somepath
is standard and
"." / somepath
is much more ugly IMO.
There is no "standard", Nim is its own programming language.
So you want two ways to do the same thing? This is really unnecessary.
/cc @dom96
also this:
import ./foo/[bar1, bar2] # works
import ../foo/[bar1, bar2] # works
import ./[bar1, bar2] # error
import ../[bar1, bar2] # error
So you want two ways to do the same thing? This is really unnecessary.
we already have 2 ways to use import with and without quotes. Quotes is typically used for cases where non-quotes would result in error, eg from the docs:
import "gfx/3d/somemodule" # in quotes because '3d' is not a valid Nim identifier
and the overwhelming majority (98% using following coarse measurement) of import uses non-quotes:
rg -A1 '\bimport '| wc -l
4180
rg -A1 '\bimport '| grep '"'| wc -l
93
Furthermore the docs says it should be allowed:
The syntax ``import dir / [moduleA, moduleB]`` can be used to import multiple modules from the same directory.
. is a valid directory
it's just a bug, and it's probably easy to fix.