-
Notifications
You must be signed in to change notification settings - Fork 424
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
allow 'use' of a directory to create nested modules #10946
Comments
One might imagine confusion if |
Just an opinion. I would prefer not to mix language features and file-system constructs if possible. This seems like it could be tricky to understand "where is module ((directoryName))" as a language feature, sort of similar to how file-level modules work today. This feature does seem like a logical extension of file-level modules though. I like that aspect of its elegance. Edit 2019-05-21: My opinion on this proposal has changed. What I want to avoid is directly incorporating filesystem constructs into the language (via e.g., |
This resonates with me. Just to make sure we're all on the same page, the behavior today in which Point being: I don't view |
There have been some discussions of adding such an idea to Rust, see
Note an important difference from what was initially proposed here:
Additionally I've read somewhere in the Rust discussions (but don't have a reference) that using a name like |
I'm on board with this proposal. Some pros/cons: Pro or Con depending on the user's opinion:
Pro:
Con:
I think it's implied that any submodule can still get to another submodule (e.g., directly calling Follow-up question: I might be wrong, but I think since Chapel today only has a global search path for modules, any |
I think you understand the situation correctly - but in this can be addressed by providing a way to anchor a |
Probably not super important right away, but what should be done in this proposal when the directory contains a symlink to another .chpl file? |
I don't expect it to do anything special, but that would allow 2 copies of the same file to be loaded in as modules with module paths (e.g. |
I think it would be nice to recognize when two modules are actually the same, so that if they accidentally would "conflict" we can just ignore the conflict if one is a symlink to the other (or both are symlinks to the same source). I think it would be fair to treat it like a copy+paste, though, and don't necessarily expect the situation to come up super often, it was just something that occurred to me because we were talking about file system organization. |
Treating it as a literal copy+paste makes sense to me. I'd like to use the filesystem for its hierarchy, but not rely too much on any particular features of the filesystem. It's a slippery slope towards considerations for hard links and case-insensitive filesystems (paired with bad module naming; the compiler might need to actually warn/enforce a style of module naming but it wouldn't help with e.g. ModuleName vs. MoDuLeName). |
This is an alternative to #10909. It includes a proposal pulled out of #8470 which was pulled out of #7847.
The idea is to allow one to
use
a directory. If that happens, each.chpl
file within that directory will be alsouse
d but they will be submodules within a module with the name of the directory. This is intended to be similar to Python packages.The idea is that the compiler can treat a directory as a module, so that all files inside of that directory would be considered nested modules.
E.g. in the example from #8470 (comment) - the user wishes to create
with the additional restriction that each submodule is stored in its own file.
How does "using" a directory enable this? Here is a sketch of the file structure:
Two tricky bits:
SuperLib
. That's what theSuperLib/Main.chpl
does in the above.use Helper
inSuperLib/Main.chpl
? SinceHelper
is meant to be a nested sub-module (rather than a top-level one), the compiler needs to know to first look inSuperLib/
for Helper rather than in other paths.The text was updated successfully, but these errors were encountered: