Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Parentheses as operators Date: Mon, 17 Aug 2015 14:40:40 -0700 Organization: None to speak of Lines: 66 Message-ID: References: <21rAx.201505$nx.48087@fx16.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="9025"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199oe70Eu9wYD8peYHWdMjh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:zXTy+WRpLatk2n6a0Ab4wCkHdhk= sha1:3GMT0cCk46yqs7Jv5EK/mLSRjX8= Xref: csiph.com comp.lang.c:67632 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Richard Heathfield writes: >>On 17/08/2015 21:17, Keith Thompson wrote: >> >>> 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. > > In > > sizeof( double ) > > , by the above, »double« seems to be an operand, but it is > not an expression itself. So then, operands are not always > expressions. The operand is not `double`, but `(double)`, and the operator is `sizeof`. > I'd only call the »sizeof« as in > > sizeof 19 > > an »operator«, while I'd call expressions such as: > > ( double )2 > > and > > sizeof( double ) > > to be »special forms«. But »special form« is no C term IIRC, > it might stem from LISP. I agree that that would be a more consistent description, and one that I'd prefer, but it's not what the standard says. > In the case of a cast ("cast operator"), I always wondered > whether > > ( double )2 > > is a binary operator with »double« and »2« as operands, > or whether it is a unary operator with »( double )« being > the operator and »2« being its sole operand. Neither. `(double)` is a cast operator, and `(double)2` is a cast-expression. The phrase "unary operator" doesn't just mean an operator with one operand (postfix ++ takes one operand but is not a unary operator), nor does "binary operator" just mean an operator with two operands ([] takes two operands but is not a binary operator). Both are specific forms defined by the grammar. -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"