Re: Is cast operator unary or binary? How many operands?



On Apr 29, 5:31 pm, rich...@xxxxxxxxxxxxxxx (Richard Tobin) wrote:
In article <13115f63-fd53-4436-879d-4dab6f0fc...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,

JoseMariaSola  <JoseMariaS...@xxxxxxxxx> wrote:
But in the case of cast the (only) operand is the expression the left,
not the type-name.

I see, you want to consider, say, (int) as an operator with a single
operand, rather than (int)x containing an operator with two operands,
"int" and "x".

This would imply an infinite number of operators, which is not
out of the question but doesn't seem to offer any advantage.

Talking with you both I notice that every operator requires
expressions as operands, and type-name is not an expression. Am I
right?

The two traditional uses of "( type-name )" - in casts and sizeof -
and the new use in C99 - in compound literals - are indeed
exceptional.  I previously suggested that we could factor out

  type-expression:
     ( type-name )

which would make sizeof in particular more regular:

  unary-expression:
     ...
     sizeof unary-expression
     sizeof type-expression

-- Richard
--
:wq

Thanks, Richard.

So both following expressions have one operator and one operand?
sizeof(int)
(int)x

typename is considered an operand in the firs expressin but not in the
second one?

JM.
.



Relevant Pages

  • Re: Sequence Point before actual function call
    ... Expressions, and it seems that 'result' is used practically ... "These operators return values that depend on the internal representations ... The unary & operator returns the address of its operand. ...
    (comp.lang.c)
  • Re: Arithmetic constant expressions and sizeof
    ... Cast operators in an arithmetic constant expression shall ... an operand to a sizeof operator whose result is an integer constant." ... sizeof expressions are allowed in ACE's, ...
    (comp.std.c)
  • Re: how to code to avoid SQL insertion attacks
    ... > the comparison of arbitrary expressions; ... > expression evaluating to NULL in that context and is not treated ... on much the same grounds that I'd object to (someBoolean IS ... NULL as an operand or 'value' of an operand in regular expressions forces the result to ...
    (comp.lang.java.programmer)
  • Re: *++p vs ++*p
    ... In my understanding, this 2 expressions are equal since '++' operator ... has a higher precedence than '*' operator. ... What is the operand of the ++ operator? ...
    (comp.lang.c)
  • excessive right shift of signed quantity
    ...   Syntax ... the result is that of the promoted left operand. ... If I understand the standard properly, shift operators are left associative, ...
    (comp.std.c)