C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Evaluating expressions with side effects.

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Jason Heyes
Guest





PostPosted: Tue Dec 21, 2004 7:16 am    Post subject: Evaluating expressions with side effects. Reply with quote



Are the side effects of evaluating expr1 resolved before expr2 is evaluated?

if (expr1 && expr2)

Thanks.


Back to top
Alf P. Steinbach
Guest





PostPosted: Tue Dec 21, 2004 7:36 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote



* Jason Heyes:
Quote:
Are the side effects of evaluating expr1 resolved before expr2 is evaluated?

if (expr1 && expr2)

Thanks.

Do get yourself a copy of the standard.

The answer is yes, except destruction of temporaries.

Now find which paragraph in the standard says exactly that! ;-)

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

Back to top
Jason Heyes
Guest





PostPosted: Tue Dec 21, 2004 7:44 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote



"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote

Quote:
* Jason Heyes:
Are the side effects of evaluating expr1 resolved before expr2 is
evaluated?

if (expr1 && expr2)

Thanks.

Do get yourself a copy of the standard.

The answer is yes, except destruction of temporaries.

Now find which paragraph in the standard says exactly that! ;-)


I rarely need to refer to the standard directly (never, in fact). So why
should I start now?



Back to top
Alf P. Steinbach
Guest





PostPosted: Tue Dec 21, 2004 7:57 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote

* Jason Heyes:
Quote:
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote in message
news:41c7d23a.498078062 (AT) news (DOT) individual.net...
* Jason Heyes:
Are the side effects of evaluating expr1 resolved before expr2 is
evaluated?

if (expr1 && expr2)

Thanks.

Do get yourself a copy of the standard.

The answer is yes, except destruction of temporaries.

Now find which paragraph in the standard says exactly that! ;-)


I rarely need to refer to the standard directly (never, in fact). So why
should I start now?

You needed it now, so the 'never' is incorrect.

Presumably the 'rarely' is also incorrect.

You should start now so that you do your work yourself instead of
asking others to do it for you.

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

Back to top
Jason Heyes
Guest





PostPosted: Tue Dec 21, 2004 8:17 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote

"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote

Quote:
* Jason Heyes:
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote in message
news:41c7d23a.498078062 (AT) news (DOT) individual.net...
* Jason Heyes:
Are the side effects of evaluating expr1 resolved before expr2 is
evaluated?

if (expr1 && expr2)

Thanks.

Do get yourself a copy of the standard.

The answer is yes, except destruction of temporaries.

Now find which paragraph in the standard says exactly that! ;-)


I rarely need to refer to the standard directly (never, in fact). So why
should I start now?

You needed it now, so the 'never' is incorrect.

Presumably the 'rarely' is also incorrect.

You should start now so that you do your work yourself instead of
asking others to do it for you.


Does this mean I can't ask questions here anymore?



Back to top
Sharad Kala
Guest





PostPosted: Tue Dec 21, 2004 8:38 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote


"Jason Heyes" <jasonheyes (AT) optusnet (DOT) com.au> wrote in message
Quote:
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote in message

asking others to do it for you.


Does this mean I can't ask questions here anymore?

Not at all. I think the point Alf is making is that to write correct and
authoritative programs one needs to have a copy of Standard. As you may be
aware that not always compilers get correct results. What do you do then ?
The answer is the Holy Standard. But I do agree that if you don't require to
use C++ daily, or in depth then probably Standard is not what you may want
to read. But for a serious C++ programmer it is a must.

Best wishes,
Sharad



Back to top
Siemel Naran
Guest





PostPosted: Tue Dec 21, 2004 10:15 am    Post subject: Re: Evaluating expressions with side effects. Reply with quote

"Jason Heyes" <jasonheyes (AT) optusnet (DOT) com.au> wrote


Quote:
Are the side effects of evaluating expr1 resolved before expr2 is
evaluated?

if (expr1 && expr2)

Yes, but only if expr1 and expr2 evaluate to fundamental types (eg. bool or
int). This is called short circuting. If expr1 and expr2 evaluate to a
class type with on overload operator&&, then the order is unspecified, as
this is just a function call.



Back to top
Jason Heyes
Guest





PostPosted: Tue Dec 21, 2004 12:03 pm    Post subject: Re: Evaluating expressions with side effects. Reply with quote

"Sharad Kala" <no_spam.sharadk_ind (AT) yahoo (DOT) com> wrote

Quote:

"Jason Heyes" <jasonheyes (AT) optusnet (DOT) com.au> wrote in message
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote in message

asking others to do it for you.


Does this mean I can't ask questions here anymore?

Not at all. I think the point Alf is making is that to write correct and
authoritative programs one needs to have a copy of Standard. As you may be
aware that not always compilers get correct results. What do you do then ?
The answer is the Holy Standard. But I do agree that if you don't require
to
use C++ daily, or in depth then probably Standard is not what you may want
to read. But for a serious C++ programmer it is a must.


Ok I understand. Where can I get the standard?



Back to top
Sharad Kala
Guest





PostPosted: Tue Dec 21, 2004 12:16 pm    Post subject: Re: Evaluating expressions with side effects. Reply with quote


"Jason Heyes" <jasonheyes (AT) optusnet (DOT) com.au> wrote in message
Quote:
"Sharad Kala" <no_spam.sharadk_ind (AT) yahoo (DOT) com> wrote in message
news:32q5m7F3oj81cU1 (AT) individual (DOT) net...

Ok I understand. Where can I get the standard?

http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.12

Sharad



Back to top
Karl Heinz Buchegger
Guest





PostPosted: Tue Dec 21, 2004 1:22 pm    Post subject: Re: Evaluating expressions with side effects. Reply with quote

Siemel Naran wrote:
Quote:

"Jason Heyes" <jasonheyes (AT) optusnet (DOT) com.au> wrote in message
news:41c7cdaf$0$1121

Are the side effects of evaluating expr1 resolved before expr2 is
evaluated?

if (expr1 && expr2)

Yes, but only if expr1 and expr2 evaluate to fundamental types (eg. bool or
int). This is called short circuting.

Note that this is not what the OP was asking about.
In C++ speak the OP asked: Is there a sequence point at &&

--
Karl Heinz Buchegger
[email]kbuchegg (AT) gascad (DOT) at[/email]

Back to top
red floyd
Guest





PostPosted: Tue Dec 21, 2004 5:17 pm    Post subject: Re: Evaluating expressions with side effects. Reply with quote

Jason Heyes wrote:
Quote:
[redacted]

Ok I understand. Where can I get the standard?



Borders/Amazon has it in hardback (Wiley Press) for about $65. I think
it includes TC1.

http://www.amazon.com/exec/obidos/tg/detail/-/0470846747/qid=1103649420

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.