Fun surprising things
Nick Sabalausky (Abscissa)
SeeWebsiteToContactMe at semitwist.com
Thu Nov 1 04:39:17 UTC 2018
On 10/31/18 10:00 AM, bauss wrote:
> What's the output of this program? (Try to figure it out without running
> it.)
>
> ```
> int c = 0;
>
> int a()
> {
> return c++;
> }
>
> int b()
> {
> return c--;
> }
I'm not sure I understand the point here. I mean, who writes code like
that? Pre/Post-incement operators? Combined with globals? To me that
just smells of trouble.
So if the issue is that the above code should result in an error but
currently doesn't, then...honestly, I'm totally onboard with that,
because it definitely strikes me as bad code. But I'm unclear about the
details. What *exact* part of it should be the error? To me, that's the
part that's not obvious. Intuitively, it strikes me as as bad code, but
to me, it's not obvious what *specifically* the compiler should be
objecting to. So, at least for me, spelling this out in more detail
would really help.
More information about the Digitalmars-d
mailing list