-
Notifications
You must be signed in to change notification settings - Fork 39
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
amended require resolution for init
files
#76
base: master
Are you sure you want to change the base?
amended require resolution for init
files
#76
Conversation
My concern with treating When a new user starts a project, they'll likely create a file called I think we can find ways to mitigate this, but fundamentally I think "promoting" a file to the parent directory introduces more problems than it solves. We need to give this some more thought, and once we have a proposal we'll share it for feedback. |
This is a valid concern. I think that if Luau were to start autocompleting imports this would be mostly negated. Additionally, I don't think this will confuse many users, as Rust does something similar and they experience minimal confusion - likely because they autocomplete imports. I am personally not a huge fan of |
This comment was marked as resolved.
This comment was marked as resolved.
I'm inclined to disagree about the footgun. Fundamentally, the way I think about this is that require-by-string is introducing module paths for the require system. We do not have a special syntax for these paths (yet? maybe we will next year when we work on import syntax), but they are not filesystem paths, and we should communicate that. If it weren't for the fact that lua already poisoned colons, I'd probably even have proposed using In this light, the structure that makes the most sense to me is to mirror how Rust deals with
Not married to any of the specific syntax really, but the overall semantics is what I think makes the most sense, really. The main variation that is sensible (and analogous to what Rust does, but people may find annoying) would be to make it so that sibling modules cannot be required directly and that the path has to go through the parent to do it. |
I feel as though the summary of this RFC should be expanded to be an actual summary of the changes, not just describe what the RFC does. Otherwise, I'm inclined to agree with this approach. Rojo wouldn't need to change (at least at a glance) and it solves the problem. These tables are very confusing and I think we should probably just commit to including a proper support for It was brought up on Discord that we could perhaps add support for |
Yeah, I talked about it with @bradsharp over lunch too, and I'm increasingly convinced that the URI-style is a nice way to do it. |
I talked to some less terminally-engaged-in-RFC devs since we've been talking about what laypeople would find intuitive, and I learned a lot and heard some good ideas from them. As a result, I've changed my mind from the other PR.
100% agree. Module paths should be unopinionated about representation - that's the platonic ideal we should be working towards. In an ideal world, we do not need to care about whether something is in a filesystem structure, or embedded in a program, especially as Luau is adopted as an embedded language in other engines.
I don't think reification is strictly necessary. Backwards compatibility absolutely is, and so I think we should support this, but I think there's also room for something a little better fit for everyone's needs together. In particular, I got the impression from talking with less technical devs that they do not like the One dev suggested something really simple: "why not just have a file and folder with the same name?". For catchiness, I'll call this the "file + directory" approach.
The reason I like this is that the parent module is always one level above the child module. Thus, when syncing between an embedded and filesystem representation, no special casing needs to be done. One concern I heard about this was that the folder and file may appear distant from each other in the file explorer, especially on Windows which shows folders in a block at the top of the list, before all files. Happily, it looks like major editors have features for supporting file nesting of exactly this variety, so I think this shouldn't be a big deal.
At first, I didn't really like these contextual aliases, but maybe they're OK. As an alternative, since paths are relative to the parent, you could also use the name of the module directly:
though of course this doesn't work quite as neatly for long names. So overall, here's where my opinion lands:
This should amortise the cost of fixing this issue over a longer time period, and means that projects don't have to hard-switch to a new syntax all at once. I personally believe this to be an optimal approach because it means that we can focus on preserving backwards compatibility fully, without encumbering non-Rojo Luau users with a myriad of confusing behaviour. The only downside I can see is that there are ambiguities introduced by supporting both, e.g.:
But given the impassioned nature of this debate, this is perhaps just a cost of doing business. |
This proposes new semantics for requiring
init
files in folders to more closely align with the Roblox DataModel and many users' understanding of howinit
files behave.Rendered.