Does this exist in any language?

Started by
12 comments, last by speciesUnknown 16 years, 8 months ago
with the following:

if(
(condition)
&& (condition)
&& (condition)
&& (condition)
)
{



}
else
{


};

does the compiler know to fail the test when one of the conditions is false? That would be part of the language specification.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Advertisement
Quote:Original post by speciesUnknown
does the compiler know to fail the test when one of the conditions is false? That would be part of the language specification.


In C and C++, yes, it's indeed part of the language specification for &&.

Quote:Original post by speciesUnknown
with the following:

if(
(condition)
&& (condition)
&& (condition)
&& (condition)
)
{



}
else
{


};

does the compiler know to fail the test when one of the conditions is false?

Yes, it does. It's called short-circuit evaluation. && is a short-circuit operator.

Quote:That would be part of the language specification.

You want to make a whole language just for this, which can already be easily done with existing languages?
no, it was just my late night thoughts.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!

This topic is closed to new replies.

Advertisement