Talk:Syntax error

Latest comment: 2 years ago by 110.225.235.203 in topic Syntax error

Logic error

edit

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)Reply

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)Reply

Insert non-formatted text here


"In computer science a syntax error refers to an error in the syntax" - well no shit surlock

Syntax Errors

edit

Hello 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

edit

I'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)Reply

Tyu

edit

Ruruf 49.37.69.74 (talk) 14:52, 15 February 2022 (UTC)Reply

Syntax error

edit

For 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)Reply