John (cc'ing rust-dev)-
You can still use the module in other contexts.
pub fn baz() {
mod z {
pub fn f () -> int { 19 }
}
fn g() -> int { use z; z::f() }
g();
}
Cheers,
-Felix
On 06/04/2013 03:50, John Clements wrote:
Our grammar currently parses modules inside functions just fine. However, it
doesn't look like it's possible to call any functions defined in one. For
instance:
fn main () {
use z;
mod z {
fn f () -> int { 19 }
}
z::f();
}
Note that the "use" has to be at the beginning of the block--that's enforced.
This gives the error:
/tmp/foo.rs:2:8: 2:10 error: failed to resolve import: z
/tmp/foo.rs:2 use z;
^~
error: failed to resolve imports
error: aborting due to 2 previous errors
It looks to me like modules are allowed here just because it's consistent with allowing
other item types--struct and enum decls, for instance. Am I missing something obvious? In
particular, I'm bad with the resolver; perhaps there's a way to write the "use"
to make this work. If not, it would seem to me like removing them would be the sensible
choice.
Thoughts?
John Clements
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.org
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev