Multiple ANDs executed one by one from left to right?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Multiple ANDs executed one by one from left to right?

Post by Bugala »

At least currently, this code works:

Code: Select all

mytable = {}

If HasItem(mytable, "test") = True And Mytable.test = 1
	DebugPrint("do the stuff")
Else
	DebugPrint("dont do the stuff")
endif
But will this also work in the future? As in, if using multiple AND conditions, is it always so that they will be executed one by one, from left to right, ignoring the rest if one of them is not true.

As in this case, if it started checking if Mytable.test = 1, it would fail, since it couldn't access Mytable.Test, since it doesn't exist. However, in this case, the previous test is to check if Mytable has item "test" in it, and as that fails, then it doesn't check the other one either.

Is this the default way Hollywood is supposed to work, as in, this is how it will work in future versions too?
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Multiple ANDs executed one by one from left to right?

Post by airsoftsoftwair »

Sure, that is called short-circuit evaluation and of course this is guaranteed to work forever. Changing such fundamental things would break lots of scripts so of course this will never behave in any other way.
Post Reply