[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ternary operator patch
- From: Mark Hamburg <mark@...>
- Date: Sat, 18 Sep 2010 10:32:15 -0700
On Sep 17, 2010, at 8:28 PM, David Manura wrote:
> On Fri, Sep 17, 2010 at 11:11 PM, David Manura <dm.lua@math2.org> wrote:
>> a = (x then y else z)
>
> Also compare:
>
> return if if x then y else z then if u then v else w else a
> return ((x then y else z) then (u then v else w) else a)
I will say, I'm actually intrigued by this approach, but from a readability standpoint I prefer having both the parentheses -- to signal that it's an expression -- and the "if" to notify one what sort of expression.
On the other hand, with or without the "if", the following seems pretty unreadable:
return (if (if x then y else z) then (if u then v else w) else a)
But "properly" formatted it might not be too bad:
return (if (if x then y else z)
then (if u then v else w)
else a)
Still not really pretty, however, but that may just be because it tries to do too much conditional branching without naming the conditions driving the branches. The code moves from "tight" to "tense".
Mark
- References:
- Re: Ternary operator patch, Henk Boom
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Geoff Leyland
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Jonathan Castello
- Re: Ternary operator patch, Roberto Ierusalimschy
- Re: Ternary operator patch, Enrico Tassi
- Re: Ternary operator patch, Doug Rogers
- Re: Ternary operator patch, Fabien
- Re: Ternary operator patch, David Manura
- Re: Ternary operator patch, David Manura