Allowing to set the globals during compilations, useful for single file modules and short scripts example:
pragma(switches, -inline -O)
This would require to isolate argument parsing from mars.d in a templatized function so that it can be reused when the pragma is processed in attributes.d. Also some switches should not be accepted when passed through the pragma.
Comment #1 by b2.temp — 2016-08-27T18:47:04Z
pragma(switches, "-inline -O");
Comment #2 by ketmar — 2016-08-28T04:12:55Z
what is wrong with:
#!rdmd -O -inline
import std.stdio;
void main () { writeln("hi!"); }
???
Comment #3 by b2.temp — 2016-08-28T04:35:59Z
(In reply to Ketmar Dark from comment #2)
> what is wrong with:
>
> #!rdmd -O -inline
> import std.stdio;
> void main () { writeln("hi!"); }
>
> ???
hint: it starts with a "Win" and ends with a "dows".
Comment #4 by ketmar — 2016-08-28T05:07:26Z
so instead of windows users writing bugreports to their OS vendor, we should add completely useless code to the compiler. i somehow doesn't feel that this solution is actually solves anything.
Comment #5 by andrej.mitrovich — 2016-08-28T14:31:35Z
I don't see why `rdmd` couldn't try to parse the file manually for shebangs and do something special on Windows. This could be an RDMD enhancement request.
Comment #6 by b2.temp — 2016-08-28T18:44:14Z
(In reply to Andrej Mitrovic from comment #5)
> I don't see why `rdmd` couldn't try to parse the file manually for shebangs
> and do something special on Windows. This could be an RDMD enhancement
> request.
I don't know I've never used rdmd at all. Idea is old:
https://forum.dlang.org/post/[email protected]
Under windows this pragma could allow to execute with "open with..." directly.
(assuming -run is among the pragma args).
Comment #7 by dlang-bugzilla — 2017-06-25T16:33:44Z
Giving the source code control over compiler behaviour is not desirable for the same reason why letting programs know (at compile time) which switches are active isn't. Many guarantees will no longer hold and debugging things reliably becomes more difficult in general.
Furthermore, a pragma is not a good place for this. Pragmas participate in semantics and can be emitted by CTFE.
Furthermore, compiler switches are heavily specific to the implementation. GDC and LDC each use different sets of switches - their compatibility layer with DMD switches comes as a stand-alone program.
Finally, this is a non-trivial change. The correct avenue for such a proposal would be a DIP.