Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #67618

Re: Parentheses as operators

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Parentheses as operators
Date 2015-08-17 13:17 -0700
Organization None to speak of
Message-ID <lnr3n1655c.fsf@kst-u.example.com> (permalink)
References <operator-20150817203200@ram.dialup.fu-berlin.de>

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:
>   To me, an operator is a sequence of fixed tokens and gaps
>   that yields an expression, when expressions are inserted
>   into the gaps. For example:
[SNIP]
>   But the parentheses usually do not count as an operator:
[SNIP]
>   Would it be wrong to call the parentheses an »operator«?

Depends on what you mean by "wrong".

The standard doesn't seem to have a definition of "operator", though I
don't see any wording that refers to parentheses as an operator.

Function calls are described in the "Postfix operators" section, but I
don't think there's any reference to a "function call operator".  If a
function call were an operator, its operands would be the
pointer-to-function expression and the arguments.  It's hard to describe
how many "operands" a function call has, and the standard doesn't try.

N1570 6.5p1 says:

    An *expression* is a sequence of operators and operands that
    specifies computation of a value, or that designates an object or a
    function, or that generates side effects, or that performs a
    combination thereof.

which is not accurate, since `42` is clearly an expression, but it has
no operators and therefore no operands.

    The value computations of the operands of an operator are sequenced
    before the value computation of the result of the operator.

That could apply as easily to `(expr)` as to `+expr`, as could the rest
of 6.5.

It seems that the standard doesn't refer to parentheses as an operator,
but it could have done so without loss of consistency or accuracy.

Call it an operator if you like -- but don't expect everyone to agree
with your usage.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Parentheses as operators Keith Thompson <kst-u@mib.org> - 2015-08-17 13:17 -0700
  Re: Parentheses as operators Richard Heathfield <rjh@cpax.org.uk> - 2015-08-17 20:57 +0100
    Re: Parentheses as operators Keith Thompson <kst-u@mib.org> - 2015-08-17 14:36 -0700
    Re: Parentheses as operators Keith Thompson <kst-u@mib.org> - 2015-08-17 14:40 -0700

csiph-web