Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / statement evaluation order

Author
Message
tmu
7
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 17th Apr 2017 20:12
Statements such as this seem to always get fully evaluated:



I would expect that the GetSpriteHitTest() would not be called. Now it gets called and crash follows.

Tricks / chance of "fix"?

PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 17th Apr 2017 20:51 Edited at: 17th Apr 2017 20:52
Easy method:


Safe method:


PSY
PSY LABS Games
Coders don't die, they just gosub without return
tmu
7
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 17th Apr 2017 20:55
Thanks PSY. I mostly do your easy method but keep forgetting it because that is not how other programming languages work. So getting lots of bugs like this..
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 17th Apr 2017 21:05
Yeah, same here
PSY LABS Games
Coders don't die, they just gosub without return
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 18th Apr 2017 00:14
@tmu: the behaviour of your example shows that the compiler could be more clever and fast.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 18th Apr 2017 00:48
It has been mentioned before about the lack of short-circuit evaluation.
Means complex checks can take a lot longer (or less if you construct your code to test the "most likely" exit condition).

Login to post a reply

Server time is: 2024-11-24 16:52:53
Your offset time is: 2024-11-24 16:52:53