octave-maintainers
[Top][All Lists]
Advanced

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

Re: Coding style: unary operators


From: Philip Nienhuis
Subject: Re: Coding style: unary operators
Date: Sat, 8 Nov 2014 07:07:58 -0800 (PST)

Juan Pablo Carbajal-2 wrote
> Hi,
> 
> Do we need to insert a blank after unary prefix operators?
> That is,
> 
>  if !flag
> 
> should it be
> 
>  if ! flag
> 
> ?
> 
> For me it doesn't make sense, other wise we would have to write "-1"
> as "- 1". Does anybody do that?

For me a space after "!" makes it easier to distinguish it from "l" (lower
L) or "1" or "|" (vertical line).
The core devs have decided this (space after !) to be the preferred style so
I just adhere to it (uhm, I try to).

"- 1" seems to work as well.
But it can be argued that a minus sign actually belongs to the following
number, just like a "+" sign would/could, rather than it being a unary
operator. So I'd say it depends on the context: 

-<space><some complicated term>  would make perfect sense; "-" is clearly a
unary operator there.

-<space>3  would make less sense (to me), I'd perceive "-3" as just a number
or quantity.

Philip




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Coding-style-unary-operators-tp4667274p4667275.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

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