[Python-Dev] Trinary Operators
Andrew Koenig
ark@research.att.com
07 Feb 2003 09:40:53 -0500
Greg> I also have a dim recollection of pestering Guido about the
Greg> statement/expression divide once, and he insisted that it was a
Greg> feature. I respectfully disagree; I think we're all grown-ups
Greg> here and we can decide between ourselves when an expression is
Greg> really a statement. This is one thing that I think C got right
Greg> (although "if (x = ...)" is an abomination that should, at the
Greg> very least, generate a stern warning).
Except that C does distinguish between expressions and statements
in a way that Algol 68 does not. For example, in C you cannot write
if (int sum = 0;
for (i = 0; i != n; ++i) sum += x[i];
sum > 0) {
// ...
}
but the corresponding construct is just fine in Algol 68:
if int sum := 0;
for i to n do sum := x[i] od;
sum > 0
then ...
fi
--
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark