Re: Funny loop with post-increment.

Jon Skeet <[email protected]> Tue, 19 Feb 2008 09:56:53 +0000
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
Ryan Heath 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?

What would you prefer? Do you want to forbid pre and post increments
completely?

> 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...

True - but this one rarely comes up. People don't often assign and
pre/post increment in the same statement, fortunately.

Jon

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com