I thought it'd be a good idea to set global immutables from args
passed to main(). When I do this:
import io = std.stdio;
immutable string abc;
void foo() {
io.writeln(abc);
}
void main(string[] args) {
abc = args[1];
foo();
}
...I get the compiler error: "Error: can only initialize const
member abc inside constructor". When I do this:
import io = std.stdio;
void foo() {
io.writeln(abc);
}
void main(string[] args) {
immutable string abc = args[1];
foo();
}
...I get the compiler error: "Error: undefined identifier abc".
Is there any workaround, or am I attempting a
stupidity/impossibility?
Thanks.
Andrew