Hasklig icon indicating copy to clipboard operation
Hasklig copied to clipboard

/= ligature doesn't work well for Ruby

Open sos4nt opened this issue 8 years ago • 7 comments

In Haskell, /= is the not-equal operator, so it seems obvious to map it to

But in Ruby (and presumably other languages, too), != is the not-equal operator and a /= b is a shortcut for a = a / b:

i = 10
i /= 2 #=> 5
i      #=> 5

# vs.

i = 10
i != 2 #=> true
i      #=> 10

Using the current ligature makes the code quite confusing:

i = 10
i ≠ 2  # will this alter i or return true?

I'm not sure how to solve it, but maybe there should be a language-agnostic base font and specialized language fonts.

sos4nt avatar Oct 21 '16 10:10 sos4nt

We can use other ligature for /= like Fira Code:

image

It still reassembles intention but is less similar to . Other option would be using other ligature for != but unfortunately /= isn't much popular as compare operator and != is popular one.

hauleth avatar Oct 21 '16 10:10 hauleth

@hauleth that looks good. I think the font should not attempt to interpret the characters or imply a meaning. It should merely make them look a bit nicer, IMO.

sos4nt avatar Oct 21 '16 11:10 sos4nt

Alternatively any of them should look like . Both could just fix spacing between symbols.

hauleth avatar Oct 21 '16 11:10 hauleth

Alternatively any of them should look like

Sorry, I don't follow. Do you mean "none of them"?

sos4nt avatar Oct 21 '16 12:10 sos4nt

I agree with @sos4nt that the font should not attempt to interpret the characters or imply a meaning. I personally would be confused to see is ruby code, though I am familiar with both Haskell and ligatures. I just don’t expect a table to magically become a chair when I sit down it.

On the other hand, /= is the division shorthand in many languages, in my opinion, it would be fine to fall back to Fira Code’s approach to preserve the meaning of /= in each language.

Nifty != ligature, just sticking ! and = together would be fine for not equal in ruby-like syntax.

am-kantox avatar Oct 21 '16 12:10 am-kantox

It's obvious that having a single font (with ligatures) for all languages is a problem, and this is yet another example.

The ideal situation is multiple font versions, and IDEs and editors that allow setting font per syntax (language).

turbohz avatar Oct 21 '16 20:10 turbohz

@hauleth But FiraCode cannot be used in Haskell, because they break ligature laws substituting != with , so you may be confused when encounter instead of != in Haskell code.

cblp avatar Jun 11 '19 09:06 cblp