Description
I have seen this on IRC today, written by @amaranth:
eval: u8::max_value()
Notice(eval): 255
eval: mod u8 { pub fn max_value() -> u32 { u32::max_value() } } u8::max_value()
Notice(eval): 4294967295
Given that modules and types have very different recommended naming scheme, I think it would make sense to merge these two namespaces by forbidding having a module with the same name as a type. This would require shuffling some things from the u8
module to the u8
type, I guess, but hopefully little that could break backwards-compatibility too much for an epoch.
As for the variables namespace, I guess it's a bit harder, given that the recommended naming scheme is the same as for modules. My perfectionist self would rather have it be merged with the others too with variables able to shadow modules, but it may be harder to pull out from a “let's not break too much retro-compatibility” perspective.
Finally, for the “Why?”, the reason is that separate namespaces:
- Make things tricky to learn (“wait so this is both a type and a module and a variable and a macro?”)
- Increase the attack surface for underhanded Rust code
What do you think about this?
Cheers,
Leo