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.

learn more… | top users | synonyms

38
votes
7answers
2k views

Why are semicolons and commas interchanged in for loops?

In many languages (a wide list, from C to JavaScript): commas , separate arguments (e.g. func(a, b, c)), while semicolons ; separate sequential instructions (e.g. instruction1; instruction2; ...
29
votes
2answers
921 views

Why do bitwise operators have lower priority than comparisons?

Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
26
votes
9answers
1k views

What is the difference between “Syntax” and “Syntactic Sugar”

Background The Wikipedia page on Syntactic Sugar states: In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. ...
2
votes
2answers
119 views

When to (enforce) linting in a software project

I'm heading a new team of developers working on a software project that makes use of continuous integration (circleci) w/ a pretty fleshed out suite of busterjs unit/integration/acceptance tests. Our ...
0
votes
0answers
10 views

Is there other syntax for this pointer operation? [migrated]

This is a really basic question, but I'm not sure how to google it. I have a pointer to a vector (or array of pointers), say vector<int *> *p; Is there an alternative syntax for indexing ...
42
votes
4answers
15k views

Why do programming languages, especially C, use curly braces and not square ones? [closed]

The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
2
votes
3answers
431 views

Checking “instanceof” rather than value using a switch statement

Is there some syntax (other than a series of if statements) that allows for the use of a switch statement in Java to check if an object is an instanceof a class? I.e., something like this: switch ...
2
votes
1answer
162 views

Are there studies about foo/bar/baz and how they inhibit or facilitate comprehension?

Preface foo,bar,baz are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to ...
11
votes
4answers
503 views

Why store a function inside a python dictionary?

I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me ...
2
votes
1answer
138 views

How are “Json.org”-like specs graphs called and how can I generate them?

In http://www.json.org Douglas Crockford shows the specs of the JSON format in two interesting ways: In the right side column he lists a text spec that looks like a YACC or LEX listing. In the main ...
7
votes
3answers
411 views

Why can't we write nested shorthand functions in Clojure?

I tried to evaluate a Clojure expression with nested shorthand functions today, and it wouldn't let me. The expression was: (#(+ % (#(+ % (* % %)) %)) 5) ; sorry for the eye bleed The output was: ...
2
votes
2answers
103 views

How to programmatically construct textual query

Here is a query language, more specifically, it's JQL, you can use it in Jira, to search for issues, it's something like SQL, but quite simpler. My case is that, I need to construct such queries ...
2
votes
5answers
340 views

Why do node packages put a comma on a newline?

I'm learning node.js and am trying out Express. My first app had this code: var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = ...
1
vote
3answers
183 views

Syntax Memorization [duplicate]

Possible Duplicate: Programmers forgetting syntax Do programmers need a good memory? I'm a new web developer. I began learning HTML/CSS around June of this year. I picked them up ...
2
votes
2answers
243 views

Why do different languages have different syntaxes? [closed]

It seems like if every language had the same core syntax but different semantics and features, new programmers or those learning a new language could focus on the theory and more abstract concepts of ...

1 2 3 4 5 7
15 30 50 per page