4 ms·
> Even allowing comparison operators like ≤, <, ≠ and = that align > consistently would be a useful start. Every text editor that understands Unicode already a
by alextingle 2y ago
> Even allowing comparison operators like ≤, <, ≠ and = that align
> consistently would be a useful start.
Every text editor that understands Unicode already allows for that. If you want to use ≤ rather than <=, then you need to alter the language, not the editor.
- swiftcoder 2y agoYou don't need to modify the language, and most popular editors already support this. You'll need to enable ligature support, and install a font that contains the appropriate ligatures (as many coding-specific fonts already do)
- auggierose 2y agoThat's not really a solution, is it, for example I don't want <= to be confused with ≤ within a string. What you propose is just one more half-baked solution that the industry is full of.
- rollcat 2y agoThat's why you need editor support for this; the lexer understands the difference between an operator and a string literal (that's how syntax highlighting works), and should be able to use ligatures in one context but not the other. (BTW I'm not a fan of coding ligatures myself, but they seem to be popular.)
- auggierose 2y agoYes, if you do it on top of the lexer it starts to make sense to me. I still think the language should also support the corresponding "ligatures", so that no confusion can result if you happen to enter ≤ directly, but this is actually a nice solution to the problem of what to do in your language aware editor when the user enters <= : nothing! You just assign to different token classes different fonts.
- Chris_Newton 2y agoTo clarify, I’m not talking about ligatures in programming fonts here. I’d like to use a slightly wider set of Unicode characters, for their designated purposes, as the main and only way to write those ideas. This could include comparison operators, arrows, maybe a few other common and easily recognisable operations. I would like to use those same characters, and where applicable with the same sizes and alignments of related characters, everywhere — in my editor, my linters and formatters, my diff tools and version control system UIs, my greybeard CLI text file batch processing incantations, everywhere. All that really needs is languages that use Unicode characters like ≤, fonts that include all the relevant glyphs, and tools that provide a simple way to enter those characters. But all of these are important, because right now we don’t have simple, standardised ways of doing these things, and so we mostly don’t do them at all. It’s obviously not a big deal, just a small “quality of life” improvement, but it’s 2024 and I don’t see any good reason why we can’t have nice things. :-)
- teo_zero 2y agoThe C committee has just deprecated trigraphs. It might be the right time to propose ≠ as alternative to != and then in 40 years we can deprecate != and only keep ≠
- satiric 2y agoHow would you type those characters? For me (on mobile) I have a few options: copy it from your message, or google "not equals sign" and copy from the browser, or add a new keyboard that contains the character. On my desktop, I could also memorize windows' alt+x code... none are fantastic options.
- teo_zero 2y agoOn mobile I keep "=" pressed for 1 sec and it allows me to type ≈ ≠ and ≡. On Linux I use the sequence Insert, "/", "=", having mapped Insert to act as a Compose key (what other use do you have for it anyway?). On Windows I use the same sequence, having installed wincompose by Sam Hocevar.
- 2y ago
- alextingle 2y agoIf your editor just blithely replaces tokens in code, then your alignments are going to be wrong. We write code in monospaced fonts for a reason.
- swiftcoder 2y agoI have never encountered a situation where shrinking the comparison operators from 2 characters to 1 caused a problem for code layout
- deleted 2y ago[deleted]