Discussion:
Fix for SL else blocks
(too old to reply)
t***@engmail.uwaterloo.ca
2004-07-01 18:36:34 UTC
Permalink
The change made to resolve the issues surrounding SL else blocks was the
addition of the sentence "The first statement of an else clause cannot be a
new if statement." to the SL spec. This seems to me to disallow the following
code:

if ... then
... # some code
else
if ... then
... # some code
endif;
... # some code
endif;

The first statement of the else clause here is a new if statement, but it's
followed by additional code. If this is disallowed, I don't see any way for
the programmer to convert such code to equally efficient permissible code.
Wouldn't it be better to say "The entire body of an else clause may not be a
single new if statement."? Or would that not have fixed the problem at all?

----------------------------------------
This mail sent through www.mywaterloo.ca
Nguyen Nguyen
2004-07-01 21:34:15 UTC
Permalink
if condA then
blockA
else
if condB then
blockB
endif;
blockC
endif;

is not valid SL. However, you (the programmer) can rewrite a logically
equivalent fragment like so:

if condA then
blockA
endif;
if (!condA) then
if condB then
blockB
endif;
blockC
endif;

The clarification that was made is necessary. Otherwise, there is
ambiguity when you encounter ELSE IF. Saying "The entire body of an else
clause may not be a single new if statement" still does not solve the
ambiguity problem.

Nguyen
Post by t***@engmail.uwaterloo.ca
The change made to resolve the issues surrounding SL else blocks was the
addition of the sentence "The first statement of an else clause cannot be a
new if statement." to the SL spec. This seems to me to disallow the following
if ... then
... # some code
else
if ... then
... # some code
endif;
... # some code
endif;
The first statement of the else clause here is a new if statement, but it's
followed by additional code. If this is disallowed, I don't see any way for
the programmer to convert such code to equally efficient permissible code.
Wouldn't it be better to say "The entire body of an else clause may not be a
single new if statement."? Or would that not have fixed the problem at all?
----------------------------------------
This mail sent through www.mywaterloo.ca
Loading...