Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't see how is that convenient? Java approach will be trivially extended with this JEP and this restriction will be lifted. C# approach probably will never be improved so it'll never be convenient to use.


It's not convenient, but it's clear.

I would love something akin to this JEP in C#, but I'd want it in a way that makes it very clear that you're executing code prior to the base class' fields being initialized.

Something along this lines of this

    public Foo(int bar)
    {
        prector
        {
            var baz = bar * bar;
            base(baz);
        }
        ctor
        {
            // Foo's constructor code
        }
    }


Since this and base are both keywords, and since () is not overloadable in C#, it adopt Java-like syntax for such calls without breaking backwards compatibility if it ever wants to do the same thing Java did.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: