Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TODO] import ./[foo1,foo2] gives error; import ./bar/[foo1,foo2] works #8792

Closed
timotheecour opened this issue Aug 28, 2018 · 7 comments
Closed

Comments

@timotheecour
Copy link
Member

No description provided.

@Araq
Copy link
Member

Araq commented Aug 28, 2018

Where is that documented to work?

@timotheecour
Copy link
Member Author

timotheecour commented Aug 28, 2018

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 #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, ...]

@Araq
Copy link
Member

Araq commented Aug 28, 2018

  1. Dots are ugly.
  2. Orthogonality of features means you need to write "." / [foo, bar] which works.

@Araq Araq closed this as completed Aug 28, 2018
@Clyybber
Copy link
Contributor

Clyybber commented Aug 28, 2018

@Araq

./somepath

is standard and

"." / somepath

is much more ugly IMO.

@Araq
Copy link
Member

Araq commented Aug 28, 2018

There is no "standard", Nim is its own programming language.

@dom96
Copy link
Contributor

dom96 commented Aug 28, 2018

So you want two ways to do the same thing? This is really unnecessary.

@timotheecour timotheecour changed the title import ./[options] does not work (gives: "Error: cannot open file: ./[options]" instead of behaving like import current_dir/[options]) [TODO] import ./[options] does not work (gives: "Error: cannot open file: ./[options]" instead of behaving like import current_dir/[options]) Aug 29, 2018
@timotheecour
Copy link
Member Author

timotheecour commented Aug 29, 2018

/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.

@timotheecour timotheecour changed the title [TODO] import ./[options] does not work (gives: "Error: cannot open file: ./[options]" instead of behaving like import current_dir/[options]) [TODO] import ./[foo1,foo2] gives error; import ./bar/[foo1,foo2] works Aug 29, 2018
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 use the workaround `".."/`
but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 7624153 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 7624153 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]

Signed-off-by: Jamie Lokier <jamie@shareable.org>
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 7624153 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]

Signed-off-by: Jamie Lokier <jamie@shareable.org>
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 7624153 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]

Signed-off-by: Jamie Lokier <jamie@shareable.org>
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 762415 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]

Signed-off-by: Jamie Lokier <jamie@shareable.org>
jlokier added a commit to status-im/nim-eth that referenced this issue Apr 7, 2021
`les_protocol.nim` failed to build, due to very silly Nim bugs
nim-lang/Nim#8792 and nim-lang/Nim#17102.

    import
      ../../[rlp, keys], ../../common/eth_types,
      ../[rlpx, kademlia, blockchain_utils], ../private/p2p_types,

The silly part is `../` has to be quoted if it's before a group of files, but
not before a single file.  Most places in PR #344 / 7624153 use the workaround
`".."/` but it was missed in `les_protocol.nim`:

    nimbus-eth1/vendor/nim-eth/eth/p2p/rlpx_protocols/les_protocol.nim(14, 3)
        Error: cannot open file: ../../[rlp,keys]

Signed-off-by: Jamie Lokier <jamie@shareable.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants