Short-circuit evaluation for "&&" and "||"

Suggest changes and improvements to Algodoo.

Short-circuit evaluation for "&&" and "||"

Postby tatt61880 » Mon Oct 11, 2010 3:39 pm

I like Short-circuit evaluation.

I suggest this because the code below returns warning, currently.
Code: Select all
Scene.my.test = 0;
(Scene.my.test == 0 || 4 / Scene.my.test == 2) ? {} : {}

-- Warning: Failed to evaluate: (Scene.my.test == 0 || 4 / Scene.my.test == 2) ? {} : {}, Division by zero
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Short-circuit evaluation for "&&" and "||"

Postby tatt61880 » Sat Mar 17, 2012 8:53 pm

Is it difficult to implement?
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Short-circuit evaluation for "&&" and "||"

Postby Kilinich » Sun Mar 18, 2012 9:07 pm

just split it into 2 if-structures
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Short-circuit evaluation for "&&" and "||"

Postby tatt61880 » Mon Mar 19, 2012 5:09 am

Kilinich wrote:just split it into 2 if-structures

I don't like unnecessary usage of if-structures.

"||" and "'&&" is normally used as short-circuit evaluation, so I expected them to behave same in Thyme.
(c.f. http://en.wikipedia.org/wiki/Short-circuit_evaluation)

In my opinion, it's not bug, so I put this in suggestion forum, but some users can consider this is a bug.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Short-circuit evaluation for "&&" and "||"

Postby Kilinich » Mon Mar 19, 2012 8:53 am

It's the same problem as true ? (1/1) : (1/0) returns error.
I don't think it's worth to care about - no big deal.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Short-circuit evaluation for "&&" and "||"

Postby monstertje3 » Mon Mar 19, 2012 6:55 pm

the true ? (1/1) : (1/0) returns probably a error because you divide by 0 (X/0=impossible)
Basically, there are only 10 types of people in the world. Those who know binary, and those who don't.
Light travels faster than sound. That's why some people appear bright until they open their mouths.
User avatar
monstertje3
 
Posts: 343
Joined: Sat Sep 05, 2009 4:29 pm
Location: N-H, NL

Re: Short-circuit evaluation for "&&" and "||"

Postby tatt61880 » Tue Mar 20, 2012 12:47 am

monstertje3 wrote:the true ? (1/1) : (1/0) returns probably a error because you divide by 0 (X/0=impossible)


1.8.0 Thyme expression error
He is talking about this.
In my opinion, it's nothing to do with my suggestion.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 11 guests