octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: formatting ?: operator


From: Mike Miller
Subject: Re: formatting ?: operator
Date: Tue, 25 Apr 2017 10:28:31 -0700
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Apr 25, 2017 at 12:19:59 -0400, John W. Eaton wrote:
> On 04/25/2017 12:02 PM, Rik wrote:
> 
> > I really like having the '?' and ':' line up vertically to show that there
> > is alternative A and alternative B.
> 
> I agree, which is why I might write
> 
>   retval = (lower
>             ? octave::math::gammainc (x, a)
>             : 1.0 - octave::math::gammainc (x, a));
> 
> even if the condition and the first expression will fit on a single line.

Back to the original topic, I agree, and it looks like those that have
chimed in agree that it should look either like this

    retval = (lower
              ? octave::math::gammainc (x, a)
              : 1.0 - octave::math::gammainc (x, a));

or this

    retval = lower
             ? octave::math::gammainc (x, a)
             : 1.0 - octave::math::gammainc (x, a);

but not this

    retval = lower ? octave::math::gammainc (x, a)
                   : 1.0 - octave::math::gammainc (x, a);

The only sticking point seems to be whether we should mandate
parentheses around the entire expression or not, right? And the main
purpose of the outer parentheses is to get emacs to indent correctly?

-- 
mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]