FiraCode icon indicating copy to clipboard operation
FiraCode copied to clipboard

Ligature Request: += and -=

Open bylatt opened this issue 9 years ago • 25 comments

bylatt avatar Apr 15 '16 10:04 bylatt

I’ve considered that very early on. Just don’t see any way how I can improve these with ligatures. Do you have something in mind?

tonsky avatar Apr 15 '16 15:04 tonsky

untitled

PranayKarani avatar Jun 04 '16 11:06 PranayKarani

I actively think these shouldn't be ligatures.

The ligatures are cool because they take multi-character strings that we think of as a single thing, and turn them into a single thing. As you say in this repo's readme, "sequences like ->... are single logical tokens."

But += is logically two tokens: addition and assignment. That's how my brain thinks of it, and I don't want the ligature to tell me otherwise. In Java at least, it's even an important distinction in multithreading contexts: a ligature-ized += would imply an "increment by" operation, which feels atomic, but the code is actually saying "take the lhs, add to it the rhs, and then assign the value back to the lhs" -- which is very much not atomic.

yshavit avatar Jun 16 '16 16:06 yshavit

But you could also interpret it as "add rhs to lhs variable" which is basically an atomic operation.

MadcapJake avatar Jun 16 '16 21:06 MadcapJake

In Java at least, it's not at all atomic. Even if you have a volatile field, var += value is non-atomic and can miss updates.

yshavit avatar Jun 16 '16 21:06 yshavit

yshavit has a point, but I also don't know what such a ligature would look like while still keeping it familiar.

I'm not sure if this is a font-rendering issue or something in Fira Code, but could the + and - be better aligned with the =?

Current: selection_034

Aligned: selection_034_2

Maybe this is just a tweak to the individual characters though.

engelfrost avatar Jun 17 '16 08:06 engelfrost

@engelfrost that’s an artefact of lowercase-aligned +. Will fix

tonsky avatar Jun 19 '16 10:06 tonsky

Here's a proposition. proposed += Top is current, bottom is proposed ligature. No connections, simply reduced kerning.

serebit avatar Jul 13 '16 19:07 serebit

I like the idea of a += ligature, and if that exists, then -= should probably exist for symmetry. But then should all the other assignment operations available in different languages also exist? In the C family there are often *= (multiply-assign), /= (divide-assign), possibly %= (modulo assign)...

JamesFaix avatar Jul 16 '16 20:07 JamesFaix

*= could have a vertically-aligned ligature with reduced kerning. /= could just have a smaller /, with better vertical alignment. Modulo assign seems fine as is.

serebit avatar Jul 16 '16 20:07 serebit

*= could even use the actual multiplication sign, ×=.

aaaxx avatar Jul 17 '16 03:07 aaaxx

I think that's a bad idea because * doesn't always mean multiplication. Plus it would be too different to discern what the underlying operator is.

On Jul 16, 2016 10:24 PM, "aaaxx" [email protected] wrote:

*= could even use the actual multiplication sign, ×=.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tonsky/FiraCode/issues/173#issuecomment-233162985, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOJdb7BN4XFOQs-sy6W63-QNaGNUGehks5qWaBQgaJpZM4IIMMk .

MadcapJake avatar Jul 17 '16 15:07 MadcapJake

@MadcapJake I see your point. I think += and -= are more valuable than *= and /=. @aaaxx I think changing *= to look like x= would be too confusing. I've never used a programming environment where 'x' was used for multiplication, and even in math textbooks a dot is often used instead of 'x' for clarity with variables named 'x'.

JamesFaix avatar Jul 18 '16 22:07 JamesFaix

I agree with improved vertical alignment and reduced kerning for +=, -=, *= and /=. I too think *= should not be rendered as a ×= because it would only add confusion.

thany avatar Aug 11 '16 12:08 thany

@yshavit — regarding the number of logical tokens: I see your point that += could be regarded as "addition and assignment" but one could also think of it as .push(), which is a single logical action.

chharvey avatar Dec 28 '17 07:12 chharvey

If we're going to list all possible operator assignments, here's two more:

  • .= Used in php to concatenate and assign strings
  • &= |= ^= ~= Used in several languages as binary or bitwise AND/OR/XOR/NOT and assign numbers
  • <<= >>= Used in several languages as bitshift left/right and assign numbers
  • := Assignment operator in Pascal/Delphi

I'm not saying it's a brilliant idea to make ligatures for all of these. I'm just saying it's not necessarily a good idea to make ligatures (even if just for alignment & kerning distance) for some of them while leaving others out of the equation.

thany avatar Jan 02 '18 11:01 thany

@thany Looks like all of those are supported, except &=.

j-f1 avatar Jan 02 '18 11:01 j-f1

Feels weird that +=, -= and *= aren't supported (which is how I got here). /= is supported so the "but it's 2 actions" reason isn't even being followed.

Even just making things align better would be nice.

robclancy avatar Aug 28 '18 16:08 robclancy

Old issue, but I was thinking about it today and found this thread. i have some suggestions of how this could be made (just rough sketches, but I think they could even be applied to ÷=, ×=,etc) plusEqual_minusEqual

Luizaguzzi avatar Jul 19 '21 18:07 Luizaguzzi

Some are quite confusing but I like #3 and #6

RubenVerg avatar Jul 20 '21 07:07 RubenVerg

I would say none of them improves readability.

alexeyten avatar Jul 20 '21 08:07 alexeyten

I agree, I would like these ligatures more for style than for improved readability

Luizaguzzi avatar Jul 20 '21 17:07 Luizaguzzi

I'm all in favour of something like the improved vertical alignment and reduced kerning for +=, -=, *= and /=. Currently it feels weird to have /= as a ligature I would love if it's an opt-in ligature only, like == there are already two variants available for /= but both are unsatisfying when using it as a divide/assign operator in my opinion.

WeiPhil avatar Jan 05 '22 20:01 WeiPhil

If we're going to list all possible operator assignments, here's two more:

* `.=` Used in php to concatenate and assign strings

In raku .= is a mutating method call. For an idea of what that can look like with vertical alignment, see Isoveka issue 1390.

I'm conflicted, but I do think of it as primarily a variation on assignment (so a single operation) and will note that mathematical operators traditionally distinguish themselves from surrounding operands by similar midway vertical alignment.

habere-et-dispertire avatar Jul 30 '22 00:07 habere-et-dispertire

There already is a ligature for .=. It just needs to be turned on via cv32. In VS Code you can set ligatures by language in your settings.json:

{
    "[php]": { "editor.fontLigatures": "'liga', 'calt', 'cv32'" },
}

MadcapJake avatar Aug 11 '22 17:08 MadcapJake