Skip to main content

Questions tagged [syntax]

For questions relating to the syntax, or overall structure, of programming languages.

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 ...
Otakuwu's user avatar
  • 705
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: ...
user23013's user avatar
  • 3,314
10 votes
6 answers
2k views

Distinguishing between constant patterns and binding patterns

Consider the following example in Rust: ...
kaya3's user avatar
  • 22.4k
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 ...
user avatar
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 ...
mousetail's user avatar
  • 9,559
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 ...
supercat's user avatar
  • 2,312
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: ...
404 Name Not Found's user avatar
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 ...
feldentm's user avatar
  • 2,418
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 ...
Марат Рамазанов's user avatar
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? ...
Silah's user avatar
  • 33
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, ...
linux_user36's user avatar
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 ...
Karl Knechtel's user avatar
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 ...
Karl Knechtel's user avatar
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 ...
Aster's user avatar
  • 3,458
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 <...
CrSb0001's user avatar
  • 183

15 30 50 per page
1
2 3 4 5
10