473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Evaluating expressions with side effects.

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

if (expr1 && expr2)

Thanks.
Jul 22 '05 #1
10 1682
* 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! ;-)

--
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?
Jul 22 '05 #2
"Alf P. Steinbach" <al***@start.no> wrote in message
news:41****************@news.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?
Jul 22 '05 #3
* Jason Heyes:
"Alf P. Steinbach" <al***@start.no> wrote in message
news:41****************@news.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?
Jul 22 '05 #4
"Alf P. Steinbach" <al***@start.no> wrote in message
news:41****************@news.individual.net...
* Jason Heyes:
"Alf P. Steinbach" <al***@start.no> wrote in message
news:41****************@news.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?
Jul 22 '05 #5

"Jason Heyes" <ja********@optusnet.com.au> wrote in message
"Alf P. Steinbach" <al***@start.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
Jul 22 '05 #6
"Jason Heyes" <ja********@optusnet.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. 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.
Jul 22 '05 #7
"Sharad Kala" <no*****************@yahoo.com> wrote in message
news:32*************@individual.net...

"Jason Heyes" <ja********@optusnet.com.au> wrote in message
"Alf P. Steinbach" <al***@start.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?
Jul 22 '05 #8

"Jason Heyes" <ja********@optusnet.com.au> wrote in message
"Sharad Kala" <no*****************@yahoo.com> wrote in message
news:32*************@individual.net... Ok I understand. Where can I get the standard?


http://www.parashift.com/c++-faq-lit....html#faq-6.12

Sharad
Jul 22 '05 #9
Siemel Naran wrote:

"Jason Heyes" <ja********@optusnet.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
kb******@gascad.at
Jul 22 '05 #10
Jason Heyes wrote:
[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...qid=1103649420
Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
12
by: Martin Johansen | last post by:
In C, what do you call that which is separated by semicolon? what is the difference between an expression and a statement? Thank you.
17
by: William L. Bahn | last post by:
=========== (N869, p8) An object is a region of data storage in the execution environment, the contents of which can represent values. When explaining this to students, is it reasonable to say...
13
by: Daniel W | last post by:
Hi! I tried to post this to comp.lang.c.moderated but it didn't seem to go through. I've got a question about volatiles in assignment expressions. I found the following code snippet in an...
20
by: Neroku | last post by:
Hello, i would like to know what the serious definition of statements and expressions is: i know an expression are evaluated to a value, i.e: 1 == 2 5+7 foo( 1,2) and a statement is...
66
by: Atmapuri | last post by:
Hi! I noticed a very funny behaviour when overloading operators on objects in C#: MyOjbects a,b,c,d; .... //objects are created and initalized here... .... b.Length = 100;
20
by: raylopez99 | last post by:
Took a look at all the fuss about "lambda expressions" from Jon Skeet's excellent book "C# in Depth". Jon has an example, reproduced below (excerpt) on lambda expressions. My n00b take: it's...
3
by: Stef Mientki | last post by:
hello, I'm trying to create a high level debugger, based on rpd2. So when the debugger enters a breakpoint, I want to display the values of all variables in the, let's say, 5 lines above the...
8
by: Aftabpasha | last post by:
In a function call like printf("%d,..",++i,++i,..) can we consider every ++i as a Full Expression? And if it is a full expression, it means there is a sequence point after every ++i. So,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.