Parentheses Operators – What Are They Called?

documentationoperatorsterminology

In most programming languages documentation where they talk about operators +-*/=<> they also include ()[] as operators.

There are unary operators, multiplicative operators, additive operators, bit shifting operators, etc. etc.

I can find no terminology that separates parentheses operators from the rest of them. Calling them just parentheses operators doesn't seem right, because they can be used in very different contexts.

Specify casts, or type conversions.

 a = (int)x;

Invoke methods.

 fooMethod();

Define order or operations.

 x = (2+4)*8;

In the above examples. What is the correct terminology for each type of parentheses. I require this for documentation purposes.

Best Answer

Not all notations are operators.

Parentheses ("(" and ")") are operators when used in an expression like a*(b+c), in which case they're often referred to as grouping operators. When used to set off the type in an expression like (int) x, they're a part of the cast notation ("(" + typename + ")"), not operators. Similarly, when used in an expression like function(), they're part of the function call notation, not operators.

Brackets ("[" and "]") are typically used as part of the indexing notation, as in a[1]. In some older languages, parentheses are used instead of brackets, owing to the lack of brackets in the character sets the languages were originally defined with.

Related Topic