Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, it would be reasonable to have something which indicated that a member would never complete normally - i.e. asserting that the point after the member was unreachable. (This could either be due to an exception or due to looping forever.)</p> <p>You'd want there to be <em>something</em> (whether in the CLR or the compiler) to come up with a backup plan for if you're wrong: what would happen if someone changed <code>Assert.Fail</code> to return normally? You'd potentially want part of code verification to be something that checked it would never return normally.</p> <p>I believe there's a blog post about this idea from someone in Microsoft... I'll see if I can find it.</p> <p>In terms of syntax for representing it, while an attribute is an obvious idea, I quite like the idea of a return type of "never". Obviously that would potentially clash with existing "never" types, but hey...</p> <p>In terms of its usefulness: the obvious workaround is to throw an exception immediately after the statement, but it's certainly annoying to have to do that. (It's generally better than a return as it means if the method you're writing this in has a return type, you don't have to specify a pointless return value - and you also don't need to make sure that all <code>out</code> parameters are assigned values.) So it's not <em>required</em> - but I think it would be nice. Whether it's the most important thing the C# team can do with their limited budget is a different matter - just to pre-empt Eric ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload