From: "John-Mason P. Shackelford" Date: 2005-05-12T12:48:49+09:00 Subject: Re: alternatives to ? : contruct Jason, >> a = b if y==z else c > I really don't like the idea of having an else/otherwise/whatever > operator that allows the results of the statement to be the first and > last pieces, and the operators and conditions all squished in the > middle. B if A else C doesn't read well to me, and would get > confusing I think, whereas if A then B else C is very natural. A year ago I would have agreed with you whole heartedly, but I've come to believe that some thoughts are better expressed with an expression modifier rather than an if block. When I am trying to emphasize an assignment, rather than a branch in execution flow, conditional expressions fit the bill nicely where the subordination of an if block (inline or not) distracts the reader from the flow of the code. The syntax below clearly expresses that my main intent with this line of code is the assignment a = b and if the reader cares to know more detail about that assignment he can see that in the ordinary case the assignment is performed when a given condition is true, though some provision is made if it isn't. I find myself wanting this as code evolves: 1. a = b 2. a = b if y==z 3. if y==z then a else b end - or - 3. y==z ? a : b Here at step three my main intent (the assignment) is now subordinated to the condition, which in this case is of secondary concern. While in some contexts emphasizing the branch will be most clear, in others it would distract the reader from more important aspects of the code. Like any language feature this syntax could be abused, but I submit that expression modifiers exist not to save keystrokes, but to convey a thought different from that communicated by an if block. The expressive power of a richer expression modifier would help me to code what I mean--which is exactly what we want out of a programming language. John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford@pearson.com http://pearsonedmeasurement.com