On Monday, 15 October 2012 at 11:20:26 UTC, bearophile wrote:
Jacob Carlborg:
How should DMD detect if you're building a (dynamic) library?
Sure it can see that you're not using -lib or -shared but what
about separate complication?
What about the need to use a compiler switch if you are
performing a separate compilation?
A related enhancement request that I'm asking for since years
is: the compiler could define a compile-time constant (like
is_main_module or something) as true if the module contains the
main, and false otherwise. This allows to have a main() in each
module. This is handy to have, it allows to compile&run modules
both as normal modules to import, or to compile and run them as
stand alone programs, like when you want a module to show a
demo of its capabilities, or just run its unittests.
Bye,
bearophile
Yes, this is a nice thing Java, .NET and Python have.