Is C++ function call an expression?
Asked Answered
M

2

7

A function produces a result, can be used as argument of another function parameter. So, is a function call like:

f(1,2,3)

be considered as an "expression"? Thanks.

Manipulate answered 4/7, 2016 at 8:48 Comment(7)
Yes, its a postfix-expression (function name) with a expression-list (arguments). See : msdn.microsoft.com/en-us/library/2az68d4d.aspxYare
@molbdnilo: I'm sure comments can be very short, e.g., just two characters. Here is an example: // ;-)Lemley
Of course real programming languages can do it with only one character # (yes, I'm trolling too).Immiscible
@DietmarKühl It's Stack Exchange comments that can't be short.Viperish
@juanchopanza OK, it's gone.Galliett
@PaulStelian That was the joke.Galliett
What made you think there could possibly be some other option?Bombe
S
13

The C++ standard (N3376, §5.1) specifies an expression as:

An expression is a sequence of operators and operands that specifies a computation. An expression can result in a value and can cause side effects.

Further in the same section (§5.2.2):

A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of expressions which constitute the arguments to the function.

In short, yes.

Som answered 4/7, 2016 at 8:55 Comment(1)
I suppose the same can be said about JavaScript?Gamesome
D
3

According to 5.2.2 [expr.call] paragraph 1 of ISO/IEC 14882:2014, a function call is a [postfix] expression:

A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses which constitute the arguments to the function. ...

Digiovanni answered 4/7, 2016 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.