[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: i = i++



i don;t understand what programming practices are we talking over here. a
statement such as i++ = i is inherently absurd because i++ yields a value
and not a pointer and thus no lvalue to accompalish assignment.

correct me if need be.
----- Original Message -----
From: "Amarendra GODBOLE" <amarg@xxxxxxxxxxxxxxxxxxxxx>
To: <linux-india-programmers@xxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 11, 2001 8:49 AM
Subject: Re: [LIP] i = i++


> On Wed, Jan 10, 2001, the greycells of P k j ~ c K expressed:
>
> > read some C faqs . they say  changing a variable in a statement which
refers it twice isn't valid . so
>
> The question of valid or invalid does not figure out here. The fact is
that, the ANSI standard says
> nothing about such statements, these are called "statements with
side-effects".
> The outcome is not predictable, as EVERY compiler is free to implement it
as it wishes.
>
> Essentially, K&R advises to avoid such statements with side effects. It is
_NOT_ a good programming
> practice at all.
>
> People administering C language tests should avoid asking such questions,
as they make no sense. ;-)
> (We have a tendency to make the C test as arcane as possible) ;-)
>
> > anything like
> > ++i = i;  or
> > ++i = i++;  or
> > printf("%d %d",++i,i++);     are not valid & thus may differ from
compiler to compiler
>                                    ^^^^^^^^^
> Cheers,
> -amar-
>
> --
> Amarendra GODBOLE (http://ag.dnsq.org)
> Public Key: http://pubkey.dnsq.org
> 18.97 deg. N / 72.83 deg. E
> +0530 GMT
>
>
>
> ---------------------------------------------
> Find out more about this and other Linux India
> mailing lists at http://lists.linux-india.org/
>