Closed bylatt closed 2 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.
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:
Aligned:
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. 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" 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 .
@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/DelphiI'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.
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)
Some are quite confusing but I like #3 and #6
I would say none of them improves readability.
I agree, I would like these ligatures more for style than for improved readability
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.
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.
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'" },
}
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?