On Monday, 15 October 2012 at 17:53:15 UTC, Andrei Alexandrescu wrote:
On 10/15/12 1:37 PM, foobar wrote:
On Monday, 15 October 2012 at 15:22:38 UTC, Andrei Alexandrescu wrote:
<snip>

Yes, this is a nice thing Java, .NET and Python have.

Wonder if a simple convention would suffice, e.g. every module that wanna defines a moduleMain(string[] args) and then you have one module
main.d that has:

void main(string[] args) { import wuddever; moduleMain(args); }


Andrei

Great idea! But why add another (redundant) level of indirection? It should go in the C main in druntime together with a mechanism to call the correct D main, by e.g. reading the module name from the command line.

Well there's a tension here: good language design generally aims at providing few general features applicable to many use cases. Encoding particular use cases in the language is warranted by either disproportionate frequency in use or disproportionate difficulty in implementing them within the language. I don't think this particular feature scores very highly in either category.


Andrei

Well, it isn't so much in the language per se as it's (mostly?) in druntime. We _already_ have code in druntime that calls the user supplied main function. All I'm suggesting is a very minor enhancement to that mechanism which does add useful convenience. Seems to me the usefulness of this greatly outweighs the implementation cost.

Reply via email to