octave-maintainers
[Top][All Lists]
Advanced

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

Re: formatting ?: operator


From: John W. Eaton
Subject: Re: formatting ?: operator
Date: Tue, 25 Apr 2017 17:51:06 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 04/25/2017 05:44 PM, Rik wrote:

Actually, I prefer this last form, but if people really want the long
form then I will live with it.  For me the tertiary operator is about a
quick if/then/else operation.  If it turns out to be three lines for
every situation then it might be clearer to just write out the logic
explicitly.

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

A quick absolute value function also looks unnecessarily long when
written in the new style

abs_x = x < 0
        ? -x
        : x;

I was only talking about where to break the expression when it won't all fit on one line. If it will fit on one line, then I wouldn't split it.

jwe








reply via email to

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