Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: enforce module directory structure more strictly #63

Merged

Conversation

chris-morgan
Copy link
Member

No description provided.

@pnkfelix
Copy link
Member

pnkfelix commented May 1, 2014

@nikomatsakis has a more general idea on how to fix the common problems here. He should probably weigh in (or Niko: if you prefer, I can write an RFC for your proposal).

times, leading to surprising incompatibility between them. This proposal does
not take away one's ability to shoot oneself in the foot should one really
desire to; it just removes almost all of the rope, leaving only mixed
metaphors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhahahahah :D

@nikomatsakis
Copy link
Contributor

@pnkfelix this is basically the "opinionated" version of what I wanted to do.

The less opinionated version would support either the mod.rs or else a pattern where the main module is "foo.rs" and submodules are "foo/bar.rs"

foo.rs
foo/bar.rs

The lenient and strict version are basically the same, except for the behaviour when the current file name is not mod.rs. In that case, the lenient version would, given a declaration mod foo, we would look for current/foo.rs (where current is the name of the current module).

@o11c
Copy link
Contributor

o11c commented May 1, 2014

More choices in things like this are bad.

@pcwalton
Copy link
Contributor

pcwalton commented May 1, 2014

This seems reasonable to me at first glance.

@alexcrichton
Copy link
Member

I also think this seems like a reasonable solution to a common problem.

@pnkfelix
Copy link
Member

pnkfelix commented May 1, 2014

i prefer @nikomatsakis 's generalized form, but I would not object to accepting this RFC, especially since I believe it to be forward-compatible with niko's generalization.

@nikomatsakis nikomatsakis changed the title RFC: sane module file system hierarchy RFC: enforce module directory structure more strictly May 1, 2014
@nikomatsakis
Copy link
Contributor

@chris-morgan I took the liberty of updating the title to be more precise and formal. Feel free to update it again if you don't think it correctly reflects your proposal.

@chris-morgan
Copy link
Member Author

@nikomatsakis the rename is fine. I wasn't enthralled with the name it had!

As for the alternative of allowing foo.rs to load foo/bar.rs, that would indeed be backwards compatible, and I could live with such a thing. I do believe that enforcing more strict conventions is a good thing, however, so I would prefer this to not head in that direction.

It's much easier for a tool to correct style if there is one, and only one, way of doing something.

@bstrie
Copy link
Contributor

bstrie commented May 6, 2014

+1 to more restrictions to make the module system clearer.

@emberian
Copy link
Member

Strong +1

@alexcrichton
Copy link
Member

We discussed this at today's meeting, and have decided to merge this.

@alexcrichton alexcrichton merged commit 6158a86 into rust-lang:master May 13, 2014
@pnkfelix
Copy link
Member

pnkfelix commented Jun 3, 2014

Just a quick note of something I've noticed since attempting to adopt the stricter style imposed here: it can yield many open buffers that are all named mod.rs.

A good editor/IDE will distinguish them in some way, e.g by using the directory that they fall in (so that the buffers are named things like mod.rs<foo> and mod.rs<bar> for foo/mod.rs and bar/mod.rs).

Nonetheless, the slightly looser semantic that Niko was proposing (which we could still add on top of this, I believe) would enable me to avoid ever using the same filename, which can ease switching between open buffers in some editors.

@nikomatsakis
Copy link
Contributor

@pnkfelix yeah, this has been mentioned a few times. I can't believe that there are editors out there that fail to make the distinction between files with the same name in distinct directories, but apparently it is true. (Hello, people, index.html?) Anyway, that is certainly one legit reason that someone might prefer foo.rs and foo/bar.rs vs foo/mod.rs and foo/bar.rs. It is interesting that node.js supports both of these styles (they call it index.js, not mod.js), but apparently foo.rs and foo/bar.rs is considered preferred? I'm not sure if that's actually true, since I'm not a big node user. Certainly, for me at least, foo/mod.rs has proven to be much more compatible with how I think mentally: the foo directory has everything related to foo.

@chris-morgan
Copy link
Member Author

Another possibility is foo/foo.rs rather than foo/mod.rs.

pcwalton added a commit that referenced this pull request Sep 18, 2014
withoutboats pushed a commit to withoutboats/rfcs that referenced this pull request Jan 15, 2017
This commits adds a `poll_cancel` method to learn about when the `Oneshot` half
of a complete/oneshot pair has gone away. This can then be used to detect when a
computation is no longer wanted.

Closes rust-lang#63
@Centril Centril added the A-modules Proposals relating to modules. label Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-modules Proposals relating to modules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.