Elvish: RFC: keep the ":" syntax in the `use` statement

Created on 28 Feb 2018  路  3Comments  路  Source: elves/elvish

The use of : as part of the module path in use, as described in the documentation to control which part of the module spec becomes the module name, is extremely useful, since one cannot always control the name of the modules. For example, if I want to use both elvish-completions/git and elvish-libs/git, this makes it possible:

  use github.com/zzamboni/elvish-completions:git
  use github.com/muesli/elvish-libs/git

Without the : syntax, the later module overrides the earlier, making it impossible to access.

@xiaq: you mentioned somewhere (but can't find it at the moment) that this syntax might be removed eventually. I would like to formally request that you keep this very useful syntax.

Most helpful comment

What about extending the syntax to allow the use of a module under a different name instead?

use github.com/muesli/elvish-libs/git as mgit

then access the module as mgit:.

This seems more general, as you might wish to import several identically named modules. Or maybe you just don't like to use a module's original name.

All 3 comments

What about extending the syntax to allow the use of a module under a different name instead?

use github.com/muesli/elvish-libs/git as mgit

then access the module as mgit:.

This seems more general, as you might wish to import several identically named modules. Or maybe you just don't like to use a module's original name.

@hanche that would work as well for me :) I proposed this since the current functionality is already there and epm packages are identified by their "full path" anyway, so it's easy to make them unique.

The plan to support importing the module under a custom name, using the syntax use some/mod &as=any-name.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krader1961 picture krader1961  路  6Comments

kalikiana picture kalikiana  路  8Comments

xiaq picture xiaq  路  4Comments

xiaq picture xiaq  路  7Comments

zzamboni picture zzamboni  路  6Comments