From: Mark Hubbart Date: 2005-05-12T08:41:45+09:00 Subject: Re: alternatives to ? : contruct On 5/11/05, gwtmp01@mac.com wrote: > On May 11, 2005, at 4:07 PM, Jason Foreman wrote: > > > > I'd prefer it with less ;'s as well: > > > > a = if (y==z): b else c end > > Is this really better than: > > a = (y==z) ? b : c > > ? A little, for readability. I like using actual words as operators whenever possible. This is, of course, excepting symbolic operators like + and -, which I learned back in first grade, and carry as much meaning as actual words. > The tertiary operator ?: can be used if you want > something terse and "if then else end" if you want something > more verbose. I'm not sure I see the need for yet another > variation. First of all, it's the ternary operator :) As for the "if then else end" statement, the dangling "end" at the... uh, *end*, is a bit of an eyesore. It's what makes me shy away from using inline conditionals like that. I've thought a couple times that it would be nice to have something like "otherwise" available. I wonder if it would be too difficult for the parser to parse these two snippets the same: ---- a = if (y==z) b else c end ---- a = if (y==z) then b else c ---- That is, if else is on the same line as the code to execute if true, with no semicolon, the "end" can be dropped. Or this, instead: ---- a = b if y==z else c ---- Can the parser definitively detect that the if...else is being used as a statement modifier in this case? Just some thoughts off the top of my head, here. I could easily waffle on them if a good case is made against it. cheers, Mark