Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Parentheses as operators |
| Date | 2015-08-17 14:36 -0700 |
| Organization | None to speak of |
| Message-ID | <lnmvxp61i8.fsf@kst-u.example.com> (permalink) |
| References | <operator-20150817203200@ram.dialup.fu-berlin.de> <lnr3n1655c.fsf@kst-u.example.com> <21rAx.201505$nx.48087@fx16.am4> |
Richard Heathfield <rjh@cpax.org.uk> writes:
> On 17/08/2015 21:17, Keith Thompson wrote:
>
> <snip>
>
>> 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.
>
> It could be argued that it is a sequence of 0 operators and 1 operand
> that specifies the computation of the value 42.
>
> <snip>
It could -- but not correctly.
N1570 6.4.6p2 defines the word "operand"
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).
I previously says that the standard doesn't define the word "operator".
I was only partially correct; this is a definition, but explicitly an
incomplete one. It *could* leave the door open to defining parentheses
an an "operator", but if the standard does so I haven't found it.
An *operand* is an entity on which an operator acts.
Which implies that there can be no operand without an operator acting on
it.
42 certainly *can* be an operand, but in a case like:
42;
it isn't.
(This is just a bit of sloppy wording. The grammar defines "expression"
unambiguously, and 42 is clearly *intended* to be an expression; the
definition in 6.5p1 just doesn't capture the intent properly.)
--
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 | Next in thread | Find similar | Unroll 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