Closed Sod-Almighty closed 7 years ago
The opinion on this will be fully reflected by my first comment in #66 (or the last).
Of course, it's a static language, not dynamic, so it could actually be done technically; the critical reason is simply the strong reduction in clarity. If you prefer balancing a thousand parentheses to skip commas, well, then there's Lisp ;-). I see you've gotten a bit infected by it, admit it was near you typed defun fn
! X-D
Just because it can be done doesn't mean it's a good choice. That fact is what brings me to propose a possible killing of one of one of my darlings to enable #97 (will post there). Some minor consistent redundancy in language is important to ensure syntax errors can be pinpointed well.
Regarding multi-line arrays: newline counts as separator whether you put a comma there or not (COMMA + NEWLINE
and NEWLINE
are both considered one separator) so .
Commas are a pain in the arse when using array literals. It's extra typing, for one. More importantly, it causes syntax errors when adding or removing lines in a multi-line literal.
I suggest that commas be optional in array literals, provided only literals are used:
Being a dynamic language, detecting function calls might be tricky. You could check if a function by that name exists in scope and throw an error, but that might be a performance hog. The simpler option is to simply allow only literals (numbers, characters, strings),
true
,false
and constants (that is, identifiers starting with a capital letter).There is prior art for this, e.g. in lisp.