1. error mess ??
- Posted by Bernie Ryan <bwryan at PCOM.NET>
Sep 10, 1999
-
Last edited Sep 11, 1999
Rob
I get the message Warning: call to foo() might be short-circuited
What does the message mean and why doesn't the message tell which call to
foo() or some hint to the location where the problem is. foo()
is called many times and when your debugging a windows program it is not
always possible to trace the hundreds of passes in the message loop.
Bernie
2. Re: error mess ??
- Posted by Robert Craig <rds at ATTCANADA.NET>
Sep 10, 1999
-
Last edited Sep 11, 1999
Bernie Ryan writes:
> I get the message Warning: call to foo() might be short-circuited
The message should be improved
so it tells you where the call to foo() is. It's on my list.
Look for a call to foo() that comes after
an "and" or "or" in an if/elsif or while statement.
Euphoria is warning you that the call to foo()
might not always take place, because of Euphoria's
"short-circuit" evaluation. e.g.
if a = b and foo() > 0 then ...
When a != b Euphoria will not bother to call foo() since
the if-condition is obviously FALSE.
Euphoria will not issue this warning when it is sure that
foo() has no side-effects, i.e. foo simply returns a value
and has no other effect such as I/O, setting global variables etc.
This warning was added in 2.1 to help detect any problems
in code developed for 2.0 or earlier when short-circuiting
did not exist and conditions were always fully evaluated.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
3. Re: error mess ??
Rob:
Here is the problem with that, if I do the following.
if foo() = 42 or foo() != xyz then
error_condition
else
do something else
end if
It is obvious that I want to short circuit this if foo() returns 42
In order to avoid the warning I either have to write 2 seperate if
statements ( more code ) or I have to set without warning on ( which I
consider a poor practice ) just so someone else does not have to
upgrade to the latest version of Euphoria.
Bernie
4. Re: error mess ??
Bernie Ryan writes:
> In order to avoid the warning I either have to write
> 2 seperate if statements ( more code ) or I have to
> set without warning on ( which I consider a poor practice )
Warnings can be turned on or off for individual include files,
or even for individual routines. You are not forced to choose
either on or off for the whole program.
In your case you could say:
without warning
procedure x()
if foo() = 42 or foo() != xyz then ...
end procedure
with warning
Also, "without warning" at the top of an include file
will only turn off warnings for that one file. When the
end of the include file is reached, the warning
setting is restored to what it originally was.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
5. Re: error mess ??
Thanks Rob I didn't think about the fact that I could turn it on before and
off after a function.
But I still think that I should not have to add code so the compiler can
run older code. After all the upgrade fron 2.0 to 2.1 did not cost any
registered user anything.
Thanks again
Bernie