Roman Ivanov <isroman....@ete.km.ru> wrote:

I know what your mean, but the example is flawed:

public void foo()
{
    if (m) {
         Object p = new Object();
         p.toString();
    }
}

You misunderstand. The idea is this:

void foo( ) {
  Object p;
  if ( m ) {
    p = new Object( );
    p.DoSomethingThatNeedsToBeDoneNow( );
  }
  // 20 lines of code here
  if ( m ) {
    p.doSomethingWeird( dataFromAbove );
  }
}

int x = {
    if (s == Dri.one)
        return 1;
    else if (s == Dri.two)
        return 2;
    else
        return 3;
}();

This works. I'm not sure how efficient it is, but that would solve the
issue with initialization without any path analysis.

I'm not sure the compiler actually does this, but it would be fairly
trivial to inline that delegate.


--
Simen

Reply via email to