4 ms·
Which programming language do you prefer then? Don't say C, because in C, whitespace obviously is significant: int a = 1; vs. inta=1; other languages, l
by tomp 15y ago
Which programming language do you prefer then? Don't say C, because in C, whitespace obviously is significant:
int a = 1;
vs.
inta=1;
other languages, like CoffeeScript and Python, simply take it to the next level.
- agscala 15y agoI think your example is a little too much. Whitespace isn't significant in C. When talking about programming languages, I don't think whitespace refers to spaces between tokens. It's mostly a reference to indentation.
- masklinn 15y ago> Whitespace isn't significant in C. As demonstrated, it is. > When talking about programming languages, I don't think whitespace refers to spaces between tokens. But that makes no sense, it is whitespace, and it has semantic significance (hence being significant). Whitespace was not significant in older versions of Fortran, and that allowed you to write DO30I=10,100 which was interpreted as DO 30 I = 10, 100 that is non-significant whitespace. Ruby has long struggled with how it interpreted its whitespace, for a long time sin (x) + y would be interpreted as sin(x + y) for instance, rather than syn(x) + y how is that not significant whitespace?
- tordek 15y agoBut that makes no sense, it is whitespace, and it has semantic significance (hence being significant). Whitespace was not significant in older versions of Fortran, and that allowed you to write DO30I=10,100 which was interpreted as DO 30 I = 10, 100 An amusing bug I saw in Expert C Programming mentioned how somebody once typed e dot instead of a comma, and DO 30 I = 10. 100 ended up interpreted as a simple real assignment: DO30I = 10.1
- rayiner 15y agoHe has a point. Whitespace is definitely significant to C's lexer, if not it's parser. When people say "significant whitespace" they're implicitly talking about "implicitly significant to the parser as well as the lexer."
- PLejeck 15y agoWhen we say whitespace, we usually mean multiple spaces at the start of a line, something known as "indentation" ;)
- thedufer 15y agos/whitespace/indentation/ You know that's what is being discussed.
- cube13 15y agoWhitespace does not control program flow in C. It only is used to separate tokens. It is not used to control program flow(like coffeescript and python). Note that: int a = 0; and int a=0; and int a = 0; are all equivalent.