This is the talk page for discussing improvements to the Syntax error article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article has not yet been rated on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
This article links to one or more target anchors that no longer exist.
Please help fix the broken anchors. You can remove this template after fixing the problems. | Reporting errors |
This was in the article as a syntax error, but I think it would compile okay:
Example of a syntaxlogic error in C:
static char *days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int i;
for(i=0;i<7;i++) printf( "Day %d: %d\n",i,days[i]);
In the above example, days[i]'s memory location in integer form is printed and not the string it contains, producing unexpected results but not failing the program.
Correct code: to output correct result instead of second %d conversion must be %s conversion sign: printf("Day %d: %s\n",i,days[i]);.
Let's come up with a better example of a syntax error. --Uncle Ed 17:36, 16 November 2006 (UTC)
- Hmm. The above was a logic error caused by a mistake in syntax. This, however, is not what is usually meant by a syntax error, which almost always is caught by the compiler and which is either flagged as "not really good" in some way.
- We need to distinguish between "caught" syntax errors and easily-misused features like indirection and dereferencing. Because C is so close to assembly language, it allows the use of memory pointers.
- I'd prefer to discuss the hazards of pointer logic in another article. It's way to deep (complex?) a concept for a general example of a syntax error. Perhaps an entire article just devoted to dereferencing errors would be good? I mean, whether to use the * or @ and what happens when you use (or omit) a sign wrongly? --Uncle Ed 15:14, 17 November 2006 (UTC)
Insert non-formatted text here
"In computer science a syntax error refers to an error in the syntax" - well no shit surlock
Syntax Errors
editHello everybody, I am not experienced in Javascript, so I just wanted to ask: Is it a syntax error when you call on a variable without defining its value? I think it might be a Name Error.
Potential vandalism
editI'm not sure where to mention this - or if I should at all - but this revision looked pretty nasty:
https://en.wikipedia.org/w/index.php?title=Syntax_error&diff=prev&oldid=638992587
I tried reverting it. Hope this helps. 81.109.93.98 (talk) 06:37, 25 March 2015 (UTC)
Tyu
editSyntax error
editFor compiled languages, syntax errors are detected at compile-time. A program will not compile until all syntax errors are corrected. For 110.225.235.203 (talk) 14:03, 17 March 2022 (UTC)