Firacode: Ligature Request: += and -=

Created on 15 Apr 2016  Â·  18Comments  Â·  Source: tonsky/FiraCode

suggestion

Most helpful comment

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

All 18 comments

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?

untitled

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.

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

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 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 that’s an artefact of lowercase-aligned +. Will fix

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

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)...

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

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

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 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'.

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.

@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.

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 Looks like all of those are supported, except &=.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aolko picture aolko  Â·  3Comments

Jhonyrod picture Jhonyrod  Â·  4Comments

alis0nc picture alis0nc  Â·  3Comments

whatisaphone picture whatisaphone  Â·  3Comments

RustemB picture RustemB  Â·  4Comments