On Wednesday, 14 March 2018 at 14:44:24 UTC, Marc wrote:
assume the files:
app.d
void main() {
import myModule : foo;
writeln(foo(...));
}
myModule.d
module myModule;
int foo(int n) { .... }
the following fail:
dmd -run app.d mymodule.d
give error like this:
Error: module `myModule` is in file 'myModule.d' which cannot
be read
but this doesn't fail:
dmd app.d mymodule.d && app
Why does -run fail here? I thought it was a shorthand to this
batch:
dmd app.d mymodule.d
app.exe
del app.exe
Not even that dmd mymodule.d -run app.d works and dmd -i -run
app.d works too.
However, at the moment -run needs to be the last parameter.
That's a more or less arbitrary restriction.
And no one has lifted it (yet).
Though there's a bit of work on that front:
https://github.com/dlang/dmd/pull/7927
The main problem is that the arguments after -run module are
passed to the program and thus -run can be ambiguous.