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


Groups > comp.lang.c > #67633

Re: Parentheses as operators

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

Show all headers | View raw


James Kuyper <jameskuyper@verizon.net> writes:
[...]
> 6.4.6p1 defines what constitutes a punctuator; parentheses are included.
>
> "A punctuator is a symbol that has independent syntactic and semantic
> significance. Depending on context, it may specify an operation to be
> performed (which in turn may yield a value or a function designator,
> produce a side effect, or some combination thereof) in which case it is
> known as an _operator_ (other forms of operator also exist in some
> contexts)." (6.4.6p2). The word "operator" is italicized, an ISO
> convention indicating that this clause is the official definition of
> that term.

`(` is a punctuator, as is `)`.  `()` is not.

If () were an operator, it would be one of the "other forms of
operator".  I suppose you could call it an "outfix operator".

Other examples of "other forms of operator" are sizeof (since it's a
keyword, not a punctuator), [], and ?: since they're not single
punctuators).

The standard provides no single complete definition of "operator".  I
suspect the authors simply felt it wasn't important to do so.

[...]

> The standard frequently refers to particular things as operators (and it
> never does so for parentheses), but it seldom says anything about
> operators in general, only specific operators. I was going to write
> "never" rather than "seldom", but I found one exception:
> 6.2.6.1p8: "Where an operator is applied to a value that has more than
> one object representation, which object representation is used shall not
> affect the value of the result."
>
> If parentheses are not operators, then this clause doesn't apply to
> parenthesized expressions.

True, but I don't think it needs to; it's covered by 6.5.1p5:

    A parenthesized expression is a primary expression. Its type and
    value are identical to those of the unparenthesized expression.

-- 
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 — Previous in thread | Find similar | Unroll thread


Thread

Re: Parentheses as operators James Kuyper <jameskuyper@verizon.net> - 2015-08-17 16:26 -0400
  Re: Parentheses as operators Keith Thompson <kst-u@mib.org> - 2015-08-17 14:45 -0700

csiph-web