1. Luckily we have c/c++ to blame on!

    But then again.. We we take a look at IOC containers then most behave through static methods and act like factory objects. So having a static Main method does reflect a bit to a factory pattern although it won’t return an object but an outcome.

    I propose to keep it the way it is :-). Contructors can’t return values thus our environment would need to know what exceptions are. They now expect a integer return value and I really don’t want to convert all those legacy .bat and .cmd files to catch exceptions… hehe..

    Ramon Smits

  2. This E# has some confusing syntax, starting a constructor with "void". 😉

    Actually returning an error code using exceptions would not be that difficult. The E# API designer could propose a standard ApplicationException(int errorcode, String message) which, if thrown would end the program using exceptions.

    There is one problem though, which is very much an OO violation. The Hello object never reaches a constructed state because the main loop is in the constructor body. Traditionally, you would only use the constructor to bring an object to a valid invariant by validating input and initialization, not to perform any real work.

    Maybe the language designer of P# thinks of this:

    public class Hello


    private string greeting;

    public Hello(string[] args)


    greeting = args[0];



    public void RunHello()


    System.Console.WriteLine("Hello, " + greeting);



    In this example the object gets constructed and initialized in the constructor, and the logic runs in a separate method, marked with an attribute so the runtime knows which method to invoke.

    Come to think of it, maybe static main() isn’t that bad after all. 😉

    Peter Hendriks

Comments are closed.