3 ms·
>Rob Pike famously explained that C needed its space-insensitive braces and semicolons in case code was transmitted through a channel that mangled whitespace.
by xigoi 4y ago
>Rob Pike famously explained that C needed its space-insensitive braces and semicolons in case code was transmitted through a channel that mangled whitespace.
But did he explain why it used semicolons, rather than periods, which would make more sense because a statement is basically a sentence?
- deleted 4y ago[deleted]
- int_19h 4y agoSemicolons as statement terminator (or separator) are at least as old as Algol-60; C merely inherited that.
- adhesive_wombat 4y agoPeriods are in struct.member identifiers and also in floating points. Using them again for end of statement would be complicated[1]. Imagine that your statements are "x = y.x = z." The compiler needs to figure out if that middle dot is saying "x member of y" or if it's a statement terminator. [1]: It's already complicated by that reuse, which is, I assume, why identifiers can't start with digits so your parser can be simpler.
- xigoi 4y agoI assume that the statement terminator was chosen first, so they could've used something else for member access, such as `\`. Though I don't know about floats.
- yissp 4y agoThey could have used a comma for floats, as is common in many non-English-speaking countries. Although I guess that might become ambiguous with its use as a parameter separator.
- dukoid 4y agoProbably because periods are used in numbers already... print 42.0
- lfnoise 4y agoSmalltalk uses periods. One thing I like about C is that I can write .1 or 1. , but most languages these days force me to add the zero: 0.1 or 1.0 .