3 ms·
I'm still annoyed that lists have delimiters at all. i.e. why not: [ 1 2 3 ] In particular syntaxes that require a delimiter and forbid a trailing delimi
by aidenn0 4y ago
I'm still annoyed that lists have delimiters at all. i.e. why not:
[ 1 2 3 ]
In particular syntaxes that require a delimiter and forbid a trailing delimiter require much more verbosity in code-generators.
This is maybe the only place where bash differs from other syntaxes but (IMO) clearly got it right.
I'm also reminded that Clojure uses a compromise where there are no delimiters, but a comma is treated as whitespace.
[edit]
Also this comes up from time to time in the Nix language; I was complaining with someone and we both were annoyed by the inconsistency; lists use no delimiter while sets (i.e. dicts) use a semicolon. I thought that sets should have no delimiters, he thought that lists should, but we both agreed that the inconsistency was jarring.+
- playingalong 4y agoThat is some kind of significant whitespace which some people hate.
- aidenn0 4y agoIt's not "significant whitespace" in the sense that it is usually used. Few complaining about significant whitespace think: foo bar = 3 Should assign 3 to a variable named "foo bar" because otherwise it's significant whitespace. The lexer already splits tokens on unquoted whitespace for most languages, so requiring a comma in lists solves ambiguity. The only real argument against it would be that this looks confusing (though it's still unambiguous!) [ 1 2 + 3 4] so one would either have to live with that or parenthesize multi-token expressions in a list. Note that due to Nix's weird function syntax, parenthesizing function-calls in lists is already required there, but c-like languages don't have this problem.
- dragonwriter 4y ago> That is some kind of significant whitespace People who hate on “significant whitespace” tend to have a fairly arbitrary set of conditions for which whitespace being significant, and in what way, bothers them.
- dragonwriter 4y ago“sequential tokens are implicitly list items in a list context” (lisp family, REBOL, and some others) works if its not clashing with something else, like “sequential tokens are implicitly function/method calls” (Ruby, Haskell) Of course, if sequences are callables that reproduce the original sequence with the argument appended, then these kind of merge, but with empty list as a prefix instead of list bracketing.
- aidenn0 4y agostrangely enough Nix uses both of those interpretations for sequential tokens, requiring parenthisization of function-calls inside a list context. Truly a language with syntax only a mother could love.