3 ms·
The lack of a terminator in python, and the optional terminator in JavaScript, has often produced weird errors for me, when the compiler and me disagree on if s
by CJefferson 9y ago
The lack of a terminator in python, and the optional terminator in JavaScript, has often produced weird errors for me, when the compiler and me disagree on if something should be interpreted as one line or two. With a semicolon, it's clearer.
Of course, missing semicolon errors are still annoyingly bad, I wish GCC and clang could produce better errors messages in this case.
- ben-schaaf 9y agoI've had similarly weird errors in python, but given the same situations its ever occurred to me in ruby. Maybe its just the way the grammar is defined, for example stuff like the following works perfectly fine in ruby while python just says "Invalid Syntax": foo = 1 + 2
- optimuspaul 9y agoyeah, ruby allows some odd stuff for sure.
- opportune 9y agoYou just need to add an escape character, "\". This is python 101 This is properly interpreted: foo = 1 + \ 2
- Too 9y agoPython will automatically escape newlines in some contexts. Another way to accomplish the above is to wrap the expression in parenthesis. foo = (1 + 2)
- ben-schaaf 9y agoOf course, the point I was making is that it's perfectly possible to write a parser that understands newline as a terminator without sacrificing these idiosyncrasies.
- nailer 9y agoI think statistically humans are more likely to encounter errors when the machines use different terminators than humans do. But we could always test and find out for sure.
- marcosdumay 9y agoYet, semantic white space creates almost no problem in Haskell. Both Python and JavaScript suffer from a bad designed feature, it's not inherent on the use of white space.