[rust-dev] Modules and visibility

Matthieu Monrocq matthieu.monrocq at gmail.com
Thu Jan 23 11:41:16 PST 2014


On Thu, Jan 23, 2014 at 7:59 PM, Patrick Walton <pcwalton at mozilla.com>wrote:

> On 1/22/14 12:37 PM, Matthias Einwag wrote:
>
>> 1. A real splitting between source files and modules
>>     One solution is an alternative include to mod Otherfile; That would
>> not automatically create a new module and put the content of the file in
>> it.
>>     So basically the same as C++ include. I know there's include!, but
>> is discouraged and from my tests also did not work for including types.
>>     The other option is to have something like Dart. There you have a
>> top level file for you module/library, where you specify which other
>> files are part of the module.
>>     Like `part "otherfile.rs <http://otherfile.rs>";` In the other files
>>
>> you specify `part of myModule;` to make clear that they belong to each
>> other.
>>
>
> For engineering reasons I really like the fact that you can always find
> the definition of any name by simply looking in the same file. Any name
> "foo" is always:
>
> 1. Defined in the same file.
>
> 2. Imported at the top of the file.
>
> 3. Defined in the prelude.
>
> For large projects, this eliminates a lot of grepping through the codebase.
>
> Patrick
>
>
And working on large projects, I can only concur with that.

Yes we all have IDEs, but when IDEs have to maintain complex internal
indexes (thanks C++) to be able to point you at the definition of the
class/function, they always break in subtle ways... on top of taking ages
to index freshly cloned projects.

-- Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140123/47ff7203/attachment.html>


More information about the Rust-dev mailing list