6

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.

13

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.

  • 2
    In some newer languages, parentheses are used as well. After all, an array is just a function from indices to values, a map is just a function from keys to values and a set is just a function from values to booleans, so why use a different syntax than a function call? – Jörg W Mittag Aug 15 '13 at 11:23
  • @Jörg Hooray Scala? – KChaloux Aug 15 '13 at 12:38
  • 1
    In C# at least, the square brackets as a pair are referred to as the "indexing operator", because indexing, like many "operators", can be overridden to provide custom behavior, in this case using a variant of property definition syntax with the "this" keyword. – KeithS Aug 15 '13 at 15:54
  • 2
    In C++, you can overload operator(), which is called the function call operator because it is invoked when you try to call an object as if it were a function. – Bart van Ingen Schenau Aug 15 '13 at 17:19
3

In short: They are typically called Operators and Punctuators in C family languages.

The definition of operation is defined as:

An operation is an action performed on one or more values either to modify the value held by one or both of the variables, or to produce a new value by combining existing values. Therefore, an operation is performed using at least one symbol and at least one value. The symbol used in an operation is called an operator. A value involved in an operation is called an operand.

Thus, there are 3 operators and one punctuator in most C family languages:

More about the examples and detailed explanation is posted here - Operators and Punctuators.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.