Questions tagged [grammar]
63 questions
113
votes
15 answers
Should I point out spelling/grammar related mistakes in someone's code?
While reviewing a co-worker's code, I came across some spelling mistakes in function names and also grammatical errors like doesUserHasPermission() instead of doesUserHavePermission() in function and variable names.
Should I point these out to him…

Rahul
- 2,119
- 2
- 14
- 23
67
votes
10 answers
Is it worth making a commit solely to resolve non-critical typos?
If I come across a non-critical typo in code (say, an errant apostrophe in a print(error) statement), is it worth making a commit to resolve that error, or should it simply be left alone?
Specifically, I'm curious about weighing the gumming-up of…

Christopher Berman
- 960
- 8
- 13
58
votes
5 answers
What does "context-free" mean in the term "context-free grammar"?
Given the amount of material that tries to explain what a context-free grammar (CFG) is, I found it surprising that very few (in my sample, less than 1 in 20) give an explanation on why such grammars are called "context-free". And, to my mind, none…

rick
- 1,945
- 2
- 19
- 16
43
votes
7 answers
Why the static data members have to be defined outside the class separately in C++ (unlike Java)?
class A {
static int foo () {} // ok
static int x; // <--- needed to be defined separately in .cpp file
};
I don't see a need of having A::x defined separately in a .cpp file (or same file for templates). Why can't be A::x declared and defined…

iammilind
- 2,232
- 4
- 24
- 35
42
votes
12 answers
Why do most programming languages have special keyword or syntax for declaring functions?
Most programming languages (both dynamically and statically typed languages) have special keyword and/or syntax that looks much different than declaring variables for declaring functions. I see functions as just as declaring another named…

pathikrit
- 570
- 5
- 8
31
votes
9 answers
What are your thoughts on Periods/Full Stops in code comments?
I saw this asked in the SO Tavern, so I'm posting the question here. I thought it an interesting question. (Of course it doesn't belong on SO, but I think it's OK here.)
Do you add periods (or, as the OP wrote, "full stops") in your code…

Moshe
- 5,022
- 2
- 30
- 49
24
votes
4 answers
How can I extract words from a sentence and determine what part of speech each is?
I want to write something that takes a sentence and identifies each word it contains and defines what part of speech each word is.
For example
Hello World, I am a sentence
would return this
verb noun, pronoun verb adjective noun
Ideally, I'd…

Vinny
- 259
- 1
- 2
- 5
19
votes
5 answers
What is the difference between syntax and grammar?
I understand the difference between syntax and semantics -
Syntax: how the symbols are combined to form a valid expression or statement.
Semantics: the meaning of those symbols that form an expression or statement.
But what is the grammar? For…

cpx
- 369
- 1
- 3
- 13
16
votes
6 answers
Is saying "JSON Object" redundant?
If JSON stands for JavaScript Object Notation, then when you say JSON object, aren't you really saying "JavaScript Object Notation Object"?
Would saying "JSON string" be more correct?
Or would it be more correct to simply say JSON? (as in "These two…

CamelBlues
- 1,145
- 1
- 6
- 14
16
votes
3 answers
Object-Oriented Programming: Why "Oriented"?
I am most of the way through my games programming degree. This is not a computer science degree, so a lot of the theory is eschewed in favour of practical portfolio building and what I see as JIT learning, which is apparently more important in the…

Excrubulent
- 376
- 2
- 10
15
votes
1 answer
What is the procedure that is followed when writing a lexer based upon a grammar?
While reading through an answer to the question Clarification about Grammars , Lexers and Parsers, the answer stated that:
[...] a BNF grammar contains all the rules you need for lexical analysis and parsing.
This came across as somewhat odd to me…

Christian Dean
- 2,790
- 1
- 22
- 38
14
votes
3 answers
Why does Forth's flexibility make a grammar inappropriate for it?
I've recently undertaken the task of writing a stack-based programming language. Before I started designing my language however, I thought it'd be a good idea to read and experiment with existing stack-based languages.
This brings me to the topic of…

Christian Dean
- 2,790
- 1
- 22
- 38
13
votes
6 answers
Another word for "removing code"
I'm creating a branch in source control to strip large parts of an application out. Whilst giving this branch a name, I started questioning if "removal" is the right word.
As I'm not specifically just removing the code, I'm also rewriting a few…

Jessica
- 349
- 2
- 9
13
votes
3 answers
How should I specify a grammar for a parser?
I have been programming for many years, but one task that still takes me inordinately long is to specify a grammar for a parser, and even after this excessive effort, I'm never sure that the grammar I've come up with is good (by any reasonable…
anon
11
votes
2 answers
Haskell memory efficiency - which is the better approach?
We are implementing a matrix compression library based on a modified two dimensional grammar syntax. Now we have two approaches for our data types -which one will be better in case of memory usage? (we want to compress something ;)).
The grammars…

Dennis Ich
- 213
- 2
- 5