If you have multiple variables on one line it's always a guess which one might be the null.
Sometimes I split one inline statement over two statements on purpose so I can easier understand what variable it's talking about if an exception occurs.
But I assume that the compiler can anyway decide to merge these lines into one 'thing'? So why can it then differentiate between the variables, but not if it's in one statement?
I assume there is a really good reason, but to understand compilers and the underlying workings better; why can't it tell me which variable (or column) is causing the nullref exception?
// NullRefException pointing to this line
if ( GetSomeItemFromX().AmountOfLolCats > GetSomeItemFromY().AmountOfLolCats )
return "yay";
vs
// now I can see which method is causing problems
int amountX = GetSomeItemFromX().AmountOfLolCats;
int amountY = GetSomeItemFromY().AmountOfLolCats;
if ( amountX > amountY )
return "yay";
A typical ASP.NET exception; which one is null
?
I hope someone can teach us about the underlyings of compilers and a better understanding of things happening under the hood and the tradeoffs that are being made on that level.