is evaluation order defined, and evaluation of conditionals
dunbarx at aol.com
dunbarx at aol.com
Mon Jun 25 22:47:36 EDT 2012
The case specifies a boolean "and". The order is unimportant in this example. If either argument is false, the case is ignored. It would not matter which was written first. The same would be true for a boolean "or, in that the order is not pertinent.
In that sense (though it is trivial) if the first condition fails, the second is ignored. I am not sure that this actually takes place internally, as I do not know how the tokens are parsed.
The ability to specify multiple conditionals, including mixed "and", "or" and "not" types, allows for compact and readable code. But these still stand alone, based entirely on their own logic. Though the order of evaluation is still not important, the construction of mixed conditionals, especially "and" mixed with "or" is critical, and must be written with care. Usually lots of parentheses are required.
Order of evaluation is intrinsically important in arithmetic expressions, of course.
Can you restate your problem? Or are you just exploring the language?
From: Jerry Jensen <jhj at jhj.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Mon, Jun 25, 2012 8:14 pm
Subject: Re: is evaluation order defined, and evaluation of conditionals
Note that exists() is only sensible for objects. From the dictionary:
"You can also specify a chunk of a container, but in this case the exists
function always returns true."
On Jun 25, 2012, at 4:17 PM, Dr. Hawkins wrote:
> Is the order in which expressions will be evaluated defined int LiveCode
> For example, if I have fields such as live_cats live_dogs and such,
> some but not others of which have corresponding fields dead_cat,
> dead_mouse, etc, can if have a construct that comes to
> case exists(dead_cat) and ("bad_smell" is among the words of dead_cat)
> If it is defined that the leftmost expression is evaluated first, and
> the right-hand only if needed to resolve the "and," I would expect
> this to work.
> If it doesn't, though, things get more difficult: using the exists()
> within the switch throws me down that path, and only down it can I
> check bad_smell.
> The Hawkins Law Firm
> Richard E. Hawkins, Esq.
> (702) 508-8462
> HawkinsLawFirm at gmail.com
> 3025 S. Maryland Parkway
> Suite A
> Las Vegas, NV 89109
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
More information about the Use-livecode