[stringtemplate-interest] "Or" and "And" operators in conditionnal always evaluate both operands ?

Sam Harwell sharwell at pixelminegames.com
Thu Sep 15 06:43:29 PDT 2011


Hi Damien,

 

Since the attributes referenced from a StringTemplate should always be pure
(no side effects), then there is no semantic difference between evaluating
or not evaluating the second argument. Are you facing a significant
performance problem due to the second evaluation?

 

Sam

 

From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Damien
Urruty
Sent: Thursday, September 15, 2011 8:01 AM
To: stringtemplate-interest at antlr.org
Subject: [stringtemplate-interest] "Or" and "And" operators in conditionnal
always evaluate both operands ?

 

Hello,

 

I can see that if we use && and || operands in conditionnals, both operands
are always evaluated, even if not necessary. For exemple, I have  : 

 

<if(a && b)>

...

<endif>

 

In my case, a is null, so it is not necessary to evaluate the second
argument, right ? Shouldn't the evaluation stop when such a case is
encountered ? It is the same for <if(a || b)> with a not null.

 

Maybe I miss something, thanks for your help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110915/4930c6bb/attachment.html 


More information about the stringtemplate-interest mailing list