return expr and if expr

ShanklandJA opus at drutx.UUCP
Tue May 15 23:49:32 AEST 1984


Doug Gwyn says:

    If one is serious about changing if & when syntax to remove ( ),
    then something else must also be changed to indicate grouping.
    The usual solution is something like
	    if cond then stmt fi
    where if, then, & fi are keywords.

Far be it from me to intrude on the original discussion about whether
"return(expr)" is better than "return expr" or vice versa (though my
stomach just rumbled something that sounded suspiciously like
"who cares?").

But Doug's statement above sure looks wrong to me.
Looks to me as though the 'if' and 'then' keywords already bracket
the condition, and the presence or absence of a 'fi' in the language
has nothing to do with whether or not the language requires the
condition to be parenthesized.  Keywords like 'fi' end up in languages
to get rid of the "which if does this else belong to" confusion, as in:

/* BEFORE: */
if a then
    if b then
	c
else d     /* indentation is misleading, "else d" goes with "if b" */

/* AFTER: */
if a then
    if b then
	c
    fi
else d
fi         /*  fee, fi, fo, fawn, ambiguity is gone! */

Jim Shankland
..!ihnp4!druxy!opus



More information about the Comp.lang.c mailing list