tonsky / FiraCode

Free monospaced font with programming ligatures
SIL Open Font License 1.1
77.08k stars 3.1k forks source link

Ligature Request: += and -= #173

Closed bylatt closed 2 years ago

tonsky commented 8 years ago

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?

PranayKarani commented 8 years ago

untitled

yshavit commented 8 years ago

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.

MadcapJake commented 8 years ago

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

yshavit commented 8 years ago

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.

engelfrost commented 8 years ago

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.

tonsky commented 8 years ago

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

serebit commented 8 years ago

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

JamesFaix commented 8 years ago

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

serebit commented 8 years ago

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

aaaxx commented 8 years ago

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

MadcapJake commented 8 years ago

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" notifications@github.com 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 .

JamesFaix commented 8 years ago

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

thany commented 8 years ago

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.

chharvey commented 6 years ago

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

thany commented 6 years ago

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

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.

j-f1 commented 6 years ago

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

robclancy commented 6 years ago

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.

Luizaguzzi commented 3 years ago

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

RubenVerg commented 3 years ago

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

alexeyten commented 3 years ago

I would say none of them improves readability.

Luizaguzzi commented 3 years ago

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

WeiPhil commented 2 years ago

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.

habere-et-dispertire commented 2 years ago

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.

MadcapJake commented 2 years ago

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'" },
}