On Thu, May 02, 2013 at 08:50:52AM -0400, Benjamin Striegel wrote:
> Are explicit `mod`s too heavyweight for this?

When I wrote the e-mail, I considered mods and rejected them, but now
that I think about it some more, it is a tempting alternative.

Downsides to mods (and counterpoints) are:

- Rightward drift
  - could be addressed by changing indentation conventions
- You are forced to use the mod when you call fn
  - maybe good
  - can often be avoided by `pub use` anyhow
- More `use` statements
  - not such a big deal, maybe even good, since dependencies are more 
fine-grained
- Doesn't apply to structs and impls of methods
  - you can declare substructs, and you can declare multiple `pub impl` 
declarations

The last point about declaring substructs is actually particularly
important for working happily within the borrow checker: that is,
having all your fields grouped into one big struct is an active
anti-pattern. Dividing your fields into substructs and declaring
methods on those substructs is much more borrowck-friendly. (I plan to
write a blog post on this at some point...)

So maybe I'll try mods for a while and see how it feels.

Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to