| |
 | Posted by Ilya Minkov in reply to Andres C. Rodriguez | Permalink Reply |
|
Ilya Minkov 
Posted in reply to Andres C. Rodriguez
| Andres C. Rodriguez schrieb:
>
> Should the following program (with no import) compile? It is not compiling for me right now.
>
> int main(char[][] args) {
> std.stdio.writefln("hello world\n");
> return 0;
> }
Import statement is requiered. There have been requests to make it optional and import silently when a fully qualified name comes (as in your example), but it was decided against, primarily for the sake of building automation - so that build tools can infer the dependencies without parsing completely, but only search for import, processing out comments and version statements.
In Java, where this is common, if a source file changes, you recompile it into the .class bytecode file, and you're done with it - other modules don't embed any dependency on the file. In D, it should provoke all files depending on it - say, the ones that import information relevant to data layout, templates, or in the case of release mode anything at all - become invalid and have to be recmpiled. It is similar to C++.
You can import into a dedicated struct to create a sort-of namespace, or you can import locally. Usually ro be used and least problematic is private import the module scope.
> Conversely, the program below does compile as expected.
Of course it does. :)
-eye
|