[rust-dev] Modules and visibility

Damien Radtke damienradtke at gmail.com
Thu Jan 23 20:39:16 PST 2014


I will say that I actually really like Go's approach to modules. It uses a
folder -> module mapping instead, so a module can consist of any number of
source files provided they all live in the same directory. If you prefer
your modules to be one big source file each, then that's easily done, but
those who want to break a module up into several files can do so easily.

As a counterargument, doesn't the ability to re-export modules effectively
give you what you want? It would still be a file -> module mapping, but as
far as the user is concerned, they just import one path that gives them
everything, giving you the ability to create a module out of sub-modules
and therefore keep file size small. I know that Haskell uses this approach.


On Thu, Jan 23, 2014 at 5:28 PM, Matthias Einwag <
matthias.einwag at googlemail.com> wrote:

> Hi,
>
>
>
> with similar engineering reasons I can argue the same way that splitting
> into multiple makes sense:
>
> 1.       When you name the file like our object you can use jump to file
> as a replacement for a Jump to Definition in more complex IDEs.
>
> 2.       When you layout your folders like the module structure is and
> the files therin like the types it is quite easy to find the actual file
> that defines something.
>
> 3.       When you have multiple  types in your module you can use
> multiple windows in your editor to work on both in parallel. This is not
> necessarily supported if you want two views  into the same file at
> different positions.
>
>
>
> Propably it’s also a matter of taste. Some people like big source files.
> Others (like me) don’t like them.
>
> In several projects or even languages (Java) it’s convention to break
> everything down in small parts.
>
> It shouldn’t be too hard to satisfy everyone here I think . This doesn’t
> ask for really big and incompatible changes to the module system. Only for
> the option to get rid of the file -> module condition.
>
>
>
> PS: Sorry that we now have 2 discussions. One on Github and this one. I
> sent it a little bit earlier before seeing the other one. However my intent
> is really more the file and privacy thing than discussing about the whole
> mod xyz and use:: functionality.
>
>
>
> Best regards
>
> Matthias
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140123/ff881fc3/attachment.html>


More information about the Rust-dev mailing list