-
Notifications
You must be signed in to change notification settings - Fork 23
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
RFC: --path:prefix:path
to resolve import prefix/suffix
#291
Comments
This is a bit similar to my |
I also want Note that nimble shells out to nim so
it subsumes it, if you allow a special token
and could simplify/generalize existing hard-coded logic for interpolated paths eg But the main point of the RFC is it works without modification to existing source files, eg
I don't think that's needed, this would restrict legitimate use case. extension: versioning
--path:cligen@1:pathto/cligen-1.0 --path:cligen@1.2:pathto/cligen-1.2
import cligen@1/foo
import cligen@1.2/foo |
|
|
this RFC improves on
--path:path
as follows:src
in nimble packages, without any of the downsides of scope pollution mentioned inimport this/foo
which resolvesthis
to <current nimble root> #267 (comment) such as this:proposal
--path:path
is extended to support this new syntax:--path:prefix:path
, which updates a key-value tableprefixes: Table[string,string]
mapping prefix to path.when
import path
is parsed, we now resolve the module as follows:notes (consequences of above rules)
note that
--path:prefix:path
operates as a key-value table, unlike--path:path
, which guarantees that only 1 dir is searched for for a given prefix and avoids inconsistencies. eg:nim r --path:compiler:/pathto/Nim1/compiler --path:compiler:/pathto/Nim2/compiler main
note that you can override a child prefix, which is an important feature (eg for debugging or customization) eg:
nim r --path:compiler:/pathto/Nim1/compiler --path:compiler/ast:/pathto/Nim1/compiler/ast_modif.nim main
It works for packages too:
nim r --path:compiler:/pathto/Nim1/compiler --path:compiler/plugins:/pathto/Nim_temp/compiler/plugins main
benefits
src
in nimble packages can now be omitted without any downside of scope pollutiontests/compiler/nim.cfg
can now containand avoids scope pollution (ie bringing everything in
$nim/
in import scope (egimport tools/deps
) even though we were just interested incompiler/*
)--path:prefix:path
where path isn't found (this would not make as much sense with--path:path
syntax)links
patchFile
is somewhat similar in spirit but different; eg it's an API for nimscript, not a cmdline flag, and doesn't allow overriding a (sub) package. in fact, it seems like--path:prefix:path
subsumespatchFile
somewhat related: offers an alternative for [TODO] [PENDING #8635] renamed: compiler.nimble -> compiler/compiler.nimble Nim#8636 and [TODO] [pending #8636] rename stdlib.nimble to std.nimble for consistency Nim#8637
configuration shim for poorly-constructed package structures nim-works/dist#5 (comment)
The text was updated successfully, but these errors were encountered: