Remove crate declarations (crate my-lovely-library) from the language and replace them by paths beginning with the path hanger externalcratesextern being a new keyword (extern.my-lovely-library).
Conceptually, we now have two roots in the module system: crate for the current crate being compiled(…) and crates for all the --linked library dependencies. For the purpose of documentation, let me inform you that before, we only had one – crate – and dependencies would be mounted into this single tree with duplicate crate declarations linking to the identical crate.
Motivations
(original motivation) Allows macros, lowering passes, synthesizers of the type inference engine to generate self-contained expressions even if they need to refer to external crates, especially the standard library core!. Before, those would need to somehow inject a crate declaration somewhere close with a hygienic name. Horrendous! One example: Lowering sequence literals. Another one: Derive macros.
Crate declarations are inconsistent with external module declarations in the regard how duplication is handled: External module declarations copy content, crate declarations _link`
Allows to use bindings from an external crate directly with a single declaration (a use declaration) instead of two (a crate and a use declaration)
Is more in line with the notion that external modules are added to your projects from the outside (whether that's a good thing or not) with --link or the crate manifest package.json5, rather than declared by the current crate (which might lead to the assumption that crate metadata is or should be in code like @(version ">=2.3.2") crate extension (whether that's a good thing or not))
Example
Currently
crate awesome
use awesome.Alpha
Beta: Type = Alpha Type
module sub =
use crate.awesome
gamma: … = awesome.stuff 0
module mu =
module nu =
crate awesome
X: Type = awesome.f …
Then
use extern.awesome.Alpha
Beta: Type = Alpha Type
module sub =
gamma: … = extern.awesome.stuff 0 ;; or `crate.awesome.stuff`
module mu =
module nu =
X: Type = extern.awesome.f … ;; or `crate.`…
Remove crate declarations (
crate my-lovely-library
) from the language and replace them by paths beginning with the path hangerexternal
crates
extern
being a new keyword (extern.my-lovely-library
).Conceptually, we now have two roots in the module system:
crate
for the current crate being compiled(…) andcrates
for all the--link
ed library dependencies. For the purpose of documentation, let me inform you that before, we only had one –crate
– and dependencies would be mounted into this single tree with duplicate crate declarations linking to the identical crate.Motivations
core
!. Before, those would need to somehow inject a crate declaration somewhere close with a hygienic name. Horrendous! One example: Lowering sequence literals. Another one: Derive macros.use
bindings from an external crate directly with a single declaration (a use declaration) instead of two (a crate and a use declaration)--link
or the crate manifestpackage.json5
, rather than declared by the current crate (which might lead to the assumption that crate metadata is or should be in code like@(version ">=2.3.2") crate extension
(whether that's a good thing or not))Example
Currently
Then