Andrei Alexandrescu:

I don't think that compares apples to apples, as the entire feature combination present into either language must be taken into account.

I agree that features must take in account the specific ecology of the other features of a language. And I agree the problem I am discussing about refers to the idea of "main module" that is currently ill defined in D (but I think it should be defined).

But the point is, I am desiring to solve this problem since years in D, so far I have written tons of lines of D1/D2 code, and I have not found a good solution.


I think for someone coming from Python, something akin to

if __name__ == "__main__":
    main()

makes good sense. In my opinion that's not a design we should copy.

I have suggested that solution just because I know it, and because it's probably easy to implement (once the idea of main module is defined). But I agree there are surely better designs to solve this problem. But some solution is desired, that Python-style solution is better than the current D situation :-) Currently I usually solve that problem wrapping the main in "static if (modulename_main)" and I compile with that version.

Bye,
bearophile

Reply via email to