octave-maintainers
[Top][All Lists]
Advanced

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

Re: Coding style: unary operators


From: Oliver Heimlich
Subject: Re: Coding style: unary operators
Date: Sat, 08 Nov 2014 16:12:59 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Am 08.11.2014 14:28, schrieb Juan Pablo Carbajal:
> 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?

Numbers together with a sign are a special case (from a compiler's point
of view): “-1” is a number literal (double-precision number -1.0) and “-
1” can be understood as uminus (1). However, with number literals there
is no use in discriminating the two in practice.

Then, the uplus/uminus operators can often be used in the sense of a
sign, e. g. +inf and -inf, where I immediately agree to omit the blank.

At first sight, using a blank would be consistent with our general
practice of using blanks between the functions names and parameters, as
well as blanks used for binary / ternary operators (colon, eq, …).

I have looked into my copy of the Chicago manual of style, 16th edition.
It says under 12.16: “Signs for binary operations … are preceded and
followed by medium spaces. … No space follows a binary operation or
relation sign when it is modifying a symbol (i.e., used as an
adjective): −1, +∞, ×5, >7.”

The latter applies to our unary operations, so I believe it is a natural
choice to use no blanks.



reply via email to

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