6 ms·
One advantage of not using {} for blocks is that they are available for other purposes, like generics or templates, instead of the terrible <>, combinations lik
by alricb 11y ago
One advantage of not using {} for blocks is that they are available for other purposes, like generics or templates, instead of the terrible <>, combinations like (::) or unicode characters.
- kuschku 11y agoWhy are <> so terrible? I mean, they’re more accessible than {}. <> is next to shift on the keyboard, {} is AltGr+7/9.
- masklinn 11y ago> Why are <> so terrible? I mean, they’re more accessible than {}. The problem is parsing complexity, they have to be disambiguated from the corresponding operators (also the right shift `>>`), so either the syntax has to be such that they can't appear in the same context and can be trivially differentiated, or you got yourself an exponentially harder to parse language.
- iSnow 11y agoSeriously? Some people either have a really weak mental model of a language or want to see problems where there are none. With the same right one could argue that {} can't be used for generics etc. since most people also have to write JS from time to time and it will confound the hell out of their language parser when switching languages.
- masklinn 11y ago> Seriously? Some people either have a really weak mental model of a language or want to see problems where there are none. Er… mate I'm talking about actual parsers here, as in the stuff that follows the tokenizer…
- fao_ 11y agoThat can be solved relatively simply with lookahead, can't it?
- nly 11y agoNope, because you can have arbitrary constant expressions within template instantiations. foo<bar<1> could be interpreted as "foo<(bar < 1)>" or "foo < bar<1>" It's undecidable without symbol lookup.
- TulliusCicero 11y agoI'm not sure what you mean here, {} looks just as accessible on the keyboard as <> to me.
- kuschku 11y agoNot everyone is on US keyboard ;)
- peferron 11y agoI use a French desktop keyboard and I've remapped left ctrl / left cmd / right cmd / right ctrl (it's a Mac) to { [ ] }. When used as modifiers they of course still perform their original function. Works like a charm, no AltGr necessary.