nested ifs
Dennis Brown
see3d at writeme.com
Thu Jan 26 08:17:41 EST 2006
I have resolved to make all my If statements to only 3 forms for
consistency:
IF condition THEN statement ELSE statement
IF condition
THEN statement
ELSE statement
IF condition
THEN
statements
ELSE
statements
END IF
Now if I could just get the complier to resolve only from these
choices, my nested ifs would always work.
The problem is that the compiler allows too many forms, and mixing of
forms.
The compiler does not prioritize by form type which can lead to not
always accepting a valid form.
Example 1 below is a valid form.
Example 2 would be mixing two forms in the same if statement.
It is not a valid interpretation in any case without adding another
end if.
Therefore, the compiler should pick example 1
If the compiler treated lines like parens for ifs, then it could also
do a better job resolving these correctly.
Dennis
On Jan 25, 2006, at 11:02 PM, Brian Yennie wrote:
> Dave, Chipp, et al.
>
> Consider that the following snippet is actually ambiguous. Notice
> two different formatting passes at exactly the same code. Now, of
> course, the first formatting actually resolves to valid code, while
> the second one is one "end if" short -- but who is the compiler to
> say which one you intended?
>
> Well, that's my theory anyway - you can't actually determine which
> "if" matches matches which "else" and "end if".
>
> 1)
> If x > y then
> doSomething1
> if a = be then doSomething2 ##problem here
> else
> doSomethng3
> end if
>
> 2)
> If x > y then
> doSomething1
> if a = be then doSomething2 ##problem here
> else
> doSomethng3
> end if
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list