-
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
Support include
statement to permit code to be split across multiple files in arbitrary ways
#10909
Comments
I believe that PR #1354 took us a step toward having our parser/lexer be able to support this by switching files when we encounter such statements. |
Ref #7847 (comment) |
Ref #10796 (comment) Also, this is relevant: "Is including headers inside a namespace always a bad idea?" |
@BryantLam - is the thumbs-down on this issue intentional? |
@mppf -- Yes. This feature isn't really appealing to me. It would work, but it would have some code-scaling issues:
module MyModule {
use Submodule1;
use Submodule2;
}
I would prefer an approach like C++ namespaces where you could "define" a module multiple times and it would be treated as logically the same. Namespace collisions don't happen all that often when you are the owner of a namespace, so I don't see the necessity of file-level modules other than the notion that you can insert code at file-scope (which could simply be treated as concatenated all together and sequentially executed from arbitrarily ordered modules). .. Or get rid of file-scope code, but that's probably too drastic. |
Does an issue for this proposal already exist? If not, would you consider creating one to illustrate what you're looking for?
It may be that I'm simply not understanding your proposal, but this statement seems odd to me: If the point of namespaces is to prevent two pieces of code that are unaware of each other from inadvertently having both define conflicting symbols with the same name, it seems weird to solve it using a solution in which two distinct pieces of code that happen to use the same name for a module get auto-merged into a single module (again, if I'm understanding properly). Maybe what I'm missing is: What does it mean to "own a namespace?" (That said, I think these questions should be answered on an issue proposing C++-like namespaces in Chapel, though, rather than one proposing an include statement... I understand that the
This code says "Make the public symbols of Submodule1 and Submodule2 available when resolving references within this scope." It doesn't say anything about injecting the contents of specific files into this file. |
I don't think I want the proposed namespace approach anymore. A simpler solution exists: files are already modules. Break the files up along module boundaries and "package" it with a top-level module by
I disagree. The Chapel doesn't have a lot of these problems because we don't have macros (yet) or a preprocessor that can wholesale include files into other files. This feature, however, proposes that exact behavior that led languages like even C++ away from using filesystem paths towards a semantic model which would assist in incremental compilation.
Right. It shouldn't be injecting files. The |
include
statement to permit a module to be split across multiple filesinclude
statement to permit code to be split across multiple files in arbitrary ways
[this is a long-term request / intention that I'm only now getting around to filing]
As a Chapel programmer, I currently have no way to have one file incorporate the contents of several other files (possibly taken from varying search paths on different compiles) without breaking them up into distinct submodules / namespaces. This feature request is for an
include
statement that would behave like C's#include
or LaTeX's\input
by replacing the statement with the literal contents of the named file.For example, this might look like:
where
bar.chpl
might be defined in the current directory or along a user-specified search path.The text was updated successfully, but these errors were encountered: