I prefere keeping crate and package, turn crate_type to package_typa, and change "mod" keyword to crate. But I don't know what rust devevelopers think
#[pkgid = "whoami"]; #[package_type = "lib"]; ... extern crate whoami ----- Gaetan 2013/12/15 Liigo Zhuang <com.li...@gmail.com> > Rust compiler compiles "crates", rustpkg manages "packages". > > When develope a library for rust, I write these code in lib.rs: > ``` > #[pkgid = "whoami"]; > #[crate_type = "lib"]; > ………… > ``` > Note, I set its "package" id, and set its "crate" type, and it is compiled > to an .so library. Now please tell me, what "it" is? A package? A crate? or > just a library? If it's a package, why I set its crate type? If it's a > crate, why I set its package id? Confusing. > > And when use it ("whoami"), I must write the code: > ``` > extern mod whoami; > ``` > Now was it transmuted to a "module"?? If it's a module, why I haven't set > its module id and module type? If it's not a module, why not use `extern > package whoami` or `extern crate whoami` here? Full of confusion. > > Can you please tell me WHAT it really is? Thank you. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The following is my answer and my solution: > > We remove "crate" everywhere. And the answer is obvious: it is a package. > > Package is a compile unit, it contains a root module (with the same name > as pkgid), and module contains sub-modules. A package may be compiled to > dynamic library, static library or executable program. "package" is a new > keyword. > > When define a package, we first write one of these lines: > ``` > package newpkg; /// pkgid is "newpkg", compile to dynamic library (.so) > package main; /// pkgid "main" means compile to executable program (.exe) > static package newpkg; /// pkgid is "newpkg", compile to static library > ``` > It replaced the #[pkgid] and #[crate_type], the doc-comments replaced the > #[desc]. > > When declare using the package, we write code: > ``` > extern package newpkg; // or … > extern package newpkg = "http://github.com/liigo/rust-newpkg#newpkg:1.0"; > ``` > The `extern package newpkg;` should be optional, because, when we write: > ``` > use newpkg::a::b; > ``` > … rust compiler always knows it's using extern package `newpkg`. (If name > conflicts with local module, compiler should emit an error.) > > Liigo, 2013-12-15. > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev