Re: Funny loop with post-increment.
silky <[email protected]> Tue, 19 Feb 2008 20:31:02 +1100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
On Feb 19, 2008 8:25 PM, Ryan Heath <[email protected]> wrote: > On Feb 19, 2008 9:44 AM, Frans Bouma <[email protected]> wrote: > > > Don't forget that this is a POST-increment. The return value of i++ is the > > > original value of i, before it was incremented. > > Then it makes sense. (but the compiler should throw a warning, as it's > > non-obvious code. For the 99% of the C# users who don't know the spec in every > > detail) > > That's my whole point. The behaviour is documented but its not > obvious. So why is C# supporting this behavior? it is obvious. it's not even a requirement to know the spec in every detail. c# and java have improved over c++ in their handling of the exact same statement (as Jon said; it's undefined in that). what isn't right is to have a statement who's result is dependant on the compiler, not the spec. > You *could* compare it to macroes, C# does not support macroes, and I > am glad it does not. > Too often macroes led to code that was not so obvious at all... this is not code that any sane person should ever write. but should they do, the answer is obvious if you understand post increment. if you don't, then okay that's fine. i'm sure there are parts of the language that you don't understand [same as anyone else]. so what do you do in this case? you learn. you test. you move on. there will be more and less complicated parts of the language. it is the way the language is. c#, hopefully, doesn't head down the path of too much complexity/"features" in place of usability/readability. c# 2.0 has the right amount of features. 3? well, i'm not sold on that yet :P maybe a few too many ... > // Ryan -- http://lets.coozi.com.au/ A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com