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

In this case, it's just that the decompiler didn't think of "else if" as a single control flow construct/keyword in the way that the original programmers did.

What was no doubt written like this:

  if(a < 1){
  }else if(a < 2){
  }else if(a < 3){
  }else{
  }
Decompiled into this:

  if(a < 1){
  }else{
    if(a < 2){
    }else{
      if(a < 3){
      }else{
      }
    }
  }


I will try this tomorrow, I am pretty sure dotPeek can recognize and output else if. Might be a coding style option though.


Wouldn’t “else if {“ and “else { if” compile to identical bytecode?


Sure, but the decompiler can choose to always decompile to "else if {", which is more readable and more likely to match the original source code.


That's my point. The compiler's choice of "else if {" or "else { if" is unrelated to the programmer's choice.


It does and at least the current dotPeek 2017.2.2 decompiles it to else if and does, other than I thought, not allow to customize it.


Obviously whatever decompiler was used here decided to do it the other way.




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

Search: