Questions tagged [syntax]
For questions relating to the syntax, or overall structure, of programming languages.
138 questions
17
votes
2
answers
4k
views
What is the origin of ++ and --?
In a lot of languages (eg Java, C++, etc), you can use ++ and -- as increment/decrement operators.
What was the origin of ...
3
votes
0
answers
177
views
Variable initialization syntax as a general statement, separate from definition and assignment
C++ notably has a way to skip initialization of members:
...
10
votes
6
answers
2k
views
Distinguishing between constant patterns and binding patterns
Consider the following example in Rust:
...
0
votes
2
answers
1k
views
“return(x);” vs. “return x;”
In most C-like languages, a call such as printf("%d", x) is followed by two parentheses; and I see that a statement such as ...
34
votes
6
answers
6k
views
Why do most languages have a complete operator precedence?
I actually drafted most of this question before the relevant stack overflow question but it's still relevant.
C has a famously confusing operator precedence order. It is divided into 15 levels and ...
6
votes
4
answers
609
views
Do any notable programming languages other than Fortran mark line continuation at the beginning of the following line?
In the first high-level language (FORTRAN), lines of text would by default be treated as individual statements, except that a card which contained something other than an asterisk or C in column 1 and ...
37
votes
7
answers
10k
views
Why do "modern" languages not provide argv and exit code in main?
C/C++ has an entrypoint int main(int argc, char **argv);, which provides the program with the arguments passed to it and a way to signal back the result:
...
9
votes
2
answers
1k
views
What's the rationale behind switch/yield in Java?
After upgrading to Java 21, I realized that the promised switch expression has several surprising properties. The most surprising part is the yield keyword which ...
4
votes
2
answers
572
views
Prior art for concatenative array language?
I am probably lazy so I don't feel like thoroughly designing and implementing a new language. But maybe it already exists? Do any programming languages exist with the following traits?
no need for ...
3
votes
1
answer
394
views
How is a python namespace implemented in terms of memory under Cpython implementation? [closed]
I am confused about the implementation of a global namespace in python .
How are variable names mapped as keys to the objects they reference as values ,since namespace is implemented as a dictionary? ...
21
votes
6
answers
5k
views
Why is array access not an infix operator?
The typical syntax for accessing an array (or list, map and similar data structures) at a specific index is a[i]. I believe C first introduced it as syntax sugar, ...
18
votes
7
answers
4k
views
The static keyword and clarity in language design
Across languages that use the word static as a keyword or reserved word, I have observed it to mean:
"This variable, despite being declared locally, shall be ...
6
votes
0
answers
318
views
What was the first language to use backslashes as escape characters in string literals?
I assume that C didn't originate the idea that, for example, the sequence \t inside a string literal should mean a tab character, that ...
3
votes
1
answer
359
views
What are the tradeoffs around supporting Unicode keywords and tokens?
Is the mass adoption of Unicode tokens as operators in general-purpose programming languages a good idea? How acceptable is such a language to ordinary users and developers?
Background
I want to ...
7
votes
2
answers
866
views
Why implement function syntax as `f a b` or `f: a b` instead of `f(a,b)`?
Sorry if I am not using the correct terminology here, I'll correct it if it turns out to be that way.
Programming languages such as Python or Mathematica typically have function syntax implemented as <...