Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [syntax]

Syntax refers to the set of rules that define how to write a correctly structured program in a language. It explicitly does not deal with the program's meaning or interpretation.

1 vote
5 answers
511 views

Why are programming instructions 'verb-initial'?

In all programming languages, every command is sorted as command-arguments. For instance, in pygame, the command to draw a rectangle to the screen is: pygame.draw.rect(surface,color,rect) This seems ...
user avatar
3 votes
2 answers
594 views

Why don't modern programming languages enforce whitespace around identifiers?

I recently fell in love with Factor , a programming language in the Forth family that enforces use of whitespace around identifiers, this allows creation of "functions" with extremely terse ...
Blin's user avatar
  • 139
1 vote
3 answers
607 views

Is "avoid misuse in other languages" a valid reason to avoid myString=="abc" in c++?

For example, I know in c++, I can use myString=="abc" to check if 2 strings are equal. However, in Java, it is comparing if 2 objects are the same object. Also in other language, for ...
wcminipgasker2023's user avatar
0 votes
0 answers
223 views

What is it about kdb/q that makes the grammar not suitable for ANTLR style parser generators?

I want to build a code analysis tool for personal use when programming in kdb/q. In order to do this, I need to be able to parse q code into an AST. I have never written a parser before. ANTLR4 seems ...
Chechy Levas's user avatar
4 votes
1 answer
475 views

Is there a way to make Rust code more succinct?

Let's take at random a well-written piece of Rust code: let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { label: Some("Shader"), flags: wgpu::ShaderFlags::...
Zomagk's user avatar
  • 261
8 votes
1 answer
379 views

What type of syntax notation is this?

SQL Server documentation uses this notation, which is very easy to understand and consume. Is this a BNF Syntax Diagram? Or is this a different type of notation? Source: SQL server documentation page ...
user497745's user avatar
0 votes
2 answers
95 views

Does Get in Repo Imply GetById?

REST APIs in virtually all languages use methods named Get to get GetById(int id). Is it ok to use this convention for repositories? Let's say I have a Professions repository for the sake of example. ...
VSO's user avatar
  • 179
6 votes
5 answers
980 views

Reasons to use (and not to use) a repeated delimiter to escape that delimiter?

For the designer of a language syntax, what are some reasons to choose a repeated delimiter to escape that delimiter, instead of having a separate escape character to escape that delimiter. A common ...
Shiania White's user avatar
-2 votes
1 answer
198 views

Is there a common agreed upon token symbol used in computer science or common across languages?

I have seen tokens like this: var message = "Hello, {Name}"; and like this: var message = "Hello, ${name}"; and like this: var message = "Hello, @NAME"; and a few ...
1.21 gigawatts's user avatar
0 votes
3 answers
894 views

Does compiler AST include functions and classes?

In most of the examples for Abstract Syntax Trees (AST), I see no function or classes. I am wondering, if the functions and classes are represented in the AST? If no, where should the functions, ...
Kate's user avatar
  • 1
1 vote
2 answers
1k views

Logically, is there a reason why ++i++ can not be a valid expression?

I had to increment my integer twice in a loop, so I thought I would try and be clever: for (int i = 0; !sl.isEmpty(); ++i++) { ... } ++i++ however is not an assignable expression, at least in GCC. ...
Anon's user avatar
  • 3,613
0 votes
4 answers
254 views

Language design : use equals symbol = both for affectation and comparison, like in MySQL

I'm currently designing a database query language and I came to wonder what should be the best syntax for the comparison operator. Most modern languages use ==, but amongst the database languages ...
ibi0tux's user avatar
  • 241
12 votes
1 answer
1k views

Which was the first language to allow underscore in numeric literals?

Java 7+ allows to use underscores in numeric literals,which do not affect the value of the literal, yet are useful for grouping. Examples from the Java 7 documentation, entitled "Underscores in ...
David Tonhofer's user avatar
1 vote
1 answer
78 views

Lexicon for syntax patterns? [closed]

I am having trouble finding a lexicon which provides terminology for the explicit patterns that are employed when parsing syntax. I am trying to write about the niggling differences between the 10+ ...
Darf Nader's user avatar
1 vote
1 answer
512 views

What is the BNF (or BNF-like) syntax for a specific number of repetitions?

I would like to write something like <byte> ::= <bit>*8 to mean that a <byte> is a sequence of exactly 8 <bit>'s. Is there a way to do this in BNF[1][2] or a widely used ...
Ana Nimbus's user avatar

15 30 50 per page
1
2 3 4 5
13