On Mon, 15 Oct 2012 06:24:57 -0500, Paulo Pinto <pj...@progtools.org> wrote:

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.


debug mixin(`void main() { /*do something*/ }`);
works but is kinda hacky, and line numbering on error messages might be one or two off.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to