Questions tagged [parentheses]

The symbols "(" and ")", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

The parentheses "(" and ")" are special cases of brackets, along with square brackets ("[" and "]") and curly brackets (or braces) ("{", "}").

Parentheses (singular parenthesis) have many uses in most programming languages, such as:

  • indicate the arguments of a function call;
  • specify the order of evaluation/execution of expressions;
  • create lists/arrays/vectors.
1024 questions
56
votes
13 answers

How can I make VS Code add parentheses when autocompleting functions?

Is is possible to tweak VS Code so that when function gets autocompleted, it is written with () instead of just plain function name? For example when I type str and autocomplete to strlen I would like to get strlen(), it saves quite some time.
54
votes
3 answers

How can I do Java annotation like @name("Luke") with no attribute inside parenthesis?

How I can do custom Java annotation with no attribute name inside parentheses? I don't want this: @annotation_name(att=valor). I just want like in Servlets, i.e: @WebServlet("/main")
Lucas Batistussi
  • 2,283
  • 3
  • 27
  • 35
53
votes
7 answers

Parentheses in Python Conditionals

I have a simple question regarding the use of parentheses in Python's conditional statements. The following two snippets work just the same but I wonder if this is only true because of its simplicity: >>> import os, socket >>> if…
Ben Keating
  • 8,206
  • 9
  • 37
  • 37
50
votes
4 answers

Escaping parentheses within parentheses for batch file

This is what I am trying to do: ( @echo This is some code that is @echo Important to echo exactly as-is @echo Even if I use parenthesis @echo for something (like this) )|clip So having that copied into clipboard. I have tried the following: ( @echo…
user1759622
  • 503
  • 1
  • 4
  • 4
49
votes
3 answers

What are the parentheses used for in a bash shell script function definition like "f () {}"? Is it different than using the "function" keyword?

I'v always wondered what they're used for? Seems silly to put them in every time if you can never put anything inside them. function_name () { #statements } Also is there anything to gain/lose with putting the function keyword at the start of a…
Mint
  • 14,388
  • 30
  • 76
  • 108
43
votes
3 answers

How to stop Eclipse from auto-adding parentheses?

If I for example type "Integer." and then hit CTRL+SPACE, and now choose "valueOf" from the list, Eclipse always adds "()" after the function name. That is really annoying to me because often times I have an already existing statement and want to…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
41
votes
4 answers

Autocomplete Method Brackets

Using: Visual Studio Pro 2013 Previous research: [1], [2], [3] I'm used to working in Java with Eclipse. My usual flow is: object. CTRL+SPACE + ENTER which autocompletes the method and places the correct curly brackets & method inputs in…
user3235057
  • 413
  • 1
  • 4
  • 5
41
votes
8 answers

The need for parentheses in macros in C

I tried to play with the definition of the macro SQR in the following code: #define SQR(x) (x*x) int main() { int a, b=3; a = SQR(b+5); // Ideally should be replaced with (3+5*5+3), though not sure. printf("%d\n",a); return…
Kushal
  • 3,112
  • 10
  • 50
  • 79
40
votes
8 answers

Why is it customary to put many closing parentheses on one line in Lisp-based languages?

Usually code looks like this: (one-thing (another-thing arg1 (f arg5 r)) (another-thing arg1 (f arg5 r))) Why doesn't it like this?: (one-thing (another-thing arg1 (f arg5 r)) (another-thing arg1 (f arg5 r)) ) It allows adding and…
Vi.
  • 37,014
  • 18
  • 93
  • 148
39
votes
31 answers

Parenthesis/Brackets Matching using Stack algorithm

For example if the parenthesis/brackets is matching in the following: ({}) (()){}() () and so on but if the parenthesis/brackets is not matching it should return false, eg: {} ({}( ){}) (() and so on. Can you please check this code? public static…
Shuvo0o
  • 489
  • 1
  • 8
  • 16
38
votes
2 answers

How do I turn off auto-parenthesis generation in Intellij IDEA?

When typing a function name (or auto completing) IDEA automatically puts the parentheses after it and puts the cursor between them: foo(|) I greatly dislike this and would much prefer it let me type the parentheses myself. Is there any way to do…
Adam Conroy
  • 381
  • 1
  • 3
  • 4
38
votes
4 answers

bash functions: enclosing the body in braces vs. parentheses

Usually, bash functions are defined using curly braces to enclose the body: foo() { ... } When working on a shell script today making extensive use of functions, I've run into problems with variables that have the same name in the called as in…
flotzilla
  • 1,181
  • 1
  • 13
  • 23
29
votes
6 answers

Quickest way to change a pair of parenthesis to brackets in vim

I am new to vim and in the process of discovering tons of interesting things that one can using this powerful editor. One particular thing that I need to do very frequently is to change a pair of parenthesis in the text to square-brackets (for…
MikeL
  • 2,369
  • 2
  • 24
  • 38
28
votes
1 answer

Bash command groups: Why do curly braces require a semicolon?

I know the difference in purpose between parentheses () and curly braces {} when grouping commands in bash. But why does the curly brace construct require a semicolon after the last command, whereas for the parentheses construct, the semicolon is…
Digital Trauma
  • 15,475
  • 3
  • 51
  • 83
28
votes
2 answers

Grouping AND and OR conditionals in PostgreSQL

I always use brackets in sql queries. But I have example: DELETE FROM prog WHERE prog_start >= $1 AND prog_start < $2 OR prog_end > $1 AND prog_end <= $2 Is it equal to : DELETE FROM prog WHERE ( prog_start >= $1 AND prog_start < $2 ) OR (…
Bdfy
  • 23,141
  • 55
  • 131
  • 179
1
2
3
68 69