Open saralilyb opened 7 years ago
There was a couple of request for getting better coverage for R. I’m not against it, but can’t think of a way to improve the rendering of those
I'll give a design a shot in a day or so.
@jtth Want to share your design idea? Would be awesome to have this in R.
I would second this, and third this for colleagues who have commented on how ugly the pipe symbol is. Has anyone made progress on this?
Maybe something like this?
It's a horizontal invert of the arrow that is shown for <-
, with the zeroes of the percent mark.
Better question is: does R (or RStudio that is) provide ligatures for more than 2 characters?
When typing ===
, I get: . I don't know if it will understand something in place for %>%
.
I don’t think R authors had anything in mind when they chose %>%
. Probably it’s just a random sequence of characters. I also think it’s unfixable, visually I mean
You could rotate the two %
and connect them to form a line with a >
through it. That way you would still have three-character width too.
I would propose to just use F# pipe ligature for %>%
. In R, custom operators are defined between percent signs, so anyone can define an operator like so %whatever% <- function(){ ...}
. R's pipe operator was actually inspired by F#'s pipe and is supposed to have similar behavior. However, since arbitrary-character operators have to be wrapped in %...%
, the pipe ended up looking like %>%
There are several other popular R operators mentioned in https://github.com/tonsky/FiraCode/issues/39. Not sure what can be done with them though.
I would second the proposal to use the F# ligature for the R pipe %>% . With respect to the #39 issue, it would be nice to have some of the other symbols changed, but I think most R developers would tell you they use the %>% in maybe 1/4 of their lines of code, it is everywhere. I think it should have the highest priority.
There was an earlier comment that RStudio does not support three-character ligatures. I am not sure about RStudio 1.0, but in RStudio 1.1 the double headed arrow <<- correctly changes to the ligature for that symbol with Fira Code.
The %
characters should be preserved — one of the rules of Fira Code AFAIK is that all of the characters stay. What about rendering %>%
like %|>%
?
There was an earlier comment that RStudio does not support three-character ligatures. I am not sure about RStudio 1.0, but in RStudio 1.1 the double headed arrow <<- correctly changes to the ligature for that symbol with Fira Code.
True!
I think most R developers would tell you they use the %>% in maybe 1/4 of their lines of code, it is everywhere
True!!!!
j-f1, could you elaborate on rule about all of the characters staying?
Would like this as well. How about removing the slashes and extra dots in the percent symbols, something like:
𐩑<𐩑
(Except maybe the dots being on the same level as the bracket, and also nicer etc)
I want the ligatures to resemble original characters combination
@bcollier
j-f1, could you elaborate on rule about all of the characters staying?
See above ⬆️ 🙂
I agree with the suggestion of something like the F# pipe ligature (right-pointing triangle). The percent signs (which are really just there because of R's requirements for custom binary operators) could be reduced to individual small circles.
Something like this: ∘▷∘ except I would stretch the triangle so it touches the circles.
Yeah, that’s beautiful! And I agree about the percentages :+1:
@timgoodman that's a lot better than what I had in mind. As long as the midline of the ∘ aligns with the centerline of the ▷ that's great!
Kind of like
(Fun design note: this induces a size illusion such that the left circle appears smaller than the right. Dunno whether it'd be better to increase the size of the leftmost circle, or just leave it.)
@holstius You want a paragraph marker and a hand? What?
Either seemed appropriate to me.
%>% is read “and then”; it does the same thing pseudo-linguistically as a paragraph break (that is, it separates “sentences”).
The “hand” is more of a visual analogy. There’s a rightward momentum.
On first read, I missed the point about preserving the elements of the original characters. In that case, both my suggestions are way off the mark.
On Mon, Dec 11, 2017 at 9:14 AM Jordan T. Thevenow-Harrison < notifications@github.com> wrote:
@holstius https://github.com/holstius You want a paragraph marker and a hand? What?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tonsky/FiraCode/issues/473#issuecomment-350791628, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyaakESgjaXanj4yI5LiNmllWKtSyb8ks5s_WLjgaJpZM4OzrQB .
One idea for all of these would be to drop the second o on the first % and the first o on the second %, then elongate the center operator character.
@tonsky Any good arguments against ??
Else I think most of us would say: please implement 😉
@tonsky and others:
Any interest in some variants inspired by the ligature for $>
?
I thought that a compromise between no resemblance to the original characters (as in the o |> o
) and a full representation of the two %
signs might be to turn the /
in the percent sign into an arrow. That sort of nests the arrow "within" a percent.
Even the compound pipe could be represented with uneven <>
@epspi I like yours better than mine. Very nice! That's more clear and visually unpacks a lot better.
Thanks @jtth Adding better compound pipe
Alternative based on arrows instead of > <
\in
which inserts the ∈ (isin) symbol, consistent with math in general.While some resemblance to the original characters is good (and we should follow the rule that each character in the original corresponds to some part of the ligature), I think it's more important that the meaning is conveyed (in the semantic sense, not the "what characters does it stand for" sense). For instance, !=
produces a ligature which doesn't bear much resemblance to an exclamation point, but that's OK because the ligature clearly represents the meaning "not equal". (Put another way, the ligature looks like the symbol that probably would have been used, if only that symbol existed as a key on the standard keyboard.)
For this reason, I still think the percentages should be de-emphasized, since they don't convey much meaning. They are just required for defining any custom binary operator in R. If not for this requirement of the R language, the author of magrittr might well have chosen |>
, given that the magrittr pipe was actually inspired by F#'s pipe, |>
(see here: https://www.r-statistics.com/2014/08/simpler-r-coding-with-pipes-the-present-and-future-of-the-magrittr-package/ ).
So, the magrittr pipe is not a random character sequence as suggested above; it's just an approximation of F#'s pipe that meets the rules of R. And F#'s pipe, it seems clear to me, is meant to have some resemblance to an arrow pointing in the direction of piping (and this is consistent with the fact that the reverse pipe resembles an arrow pointing the other way).
With all that said, I don't particularly care for the suggestion using diagonal arrows, because instead of using an arrow from x to f to represent "x piped into f", they use an arrow pointed off at an oblique angle, which seems less connected to the meaning. Moreover, while they increase the resemblance to the percent sign (the semantically-irrelevant part), they actually decrease the resemblance to the greater-than symbol (the semantically-important part). Even the suggestion before that, which is closer to resembling the greater-than sign, seems like it's favoring a resemblance to the percent sign a bit too much in my opinion.
So, I would still prefer the closed triangle with dots on either end, which:
%in%
maps to something like: o∈o
assuming that the membership sign spans two character widths - is that possible? (note that in addition to being ignorant, I'm too lazy above to make real circles and just used lower-case 'o')%%
, which is actually called the remainder and the floor of integer division is called the modulus. As in:
A = modulus * divisor + remainder
And yes, probably Backus' fault, as I believe it first showed up in Fortran, but for some reason, computer languages use the term 'mod' to designate the remainder.
In the long run, one reason ligatures are a great thing is that they can be used to close this gap, so it's probably a good idea not to use them to widen it.I would very much love to see ligatures for these R operators, but I think it is imperative to keep (each) ligature's shape within close proximity of the original shape of the operator, in line with what the rest of the Fira Code ligatures do. (They all just slightly move around, enlarge and reduce, and extend/warp the sub-shapes. The most drastic changes appear in >>= and |>, and still here you can see the original shapes.)
Because the choice of the percentage sign is awkward and unfortunate (as @BStudent notes) and has no semantic relation to the operator (as opposed to say >= and !=), we cannot and should indeed refrain from trying to "semanticize" them. Moreover, because entire words can be used between the percentage signs, as in %between% and %in%, such an attempt would only lead to weird solutions.
I would propose just a minor de-emphasization or subtle change of presentation of the percentage signs, for example:
This obviously makes the operator more legible, while retaining the visual characteristic of the original operator (beit awkwardly chosen or not).
How about changing the >
in %>%
into the |>
ligature?
@j-f1 : that replacement would not generalize well to %in%
and %between%
.
I'm convinced that Fira Code (or any other symbols-ligaturing font) should stay well away from the programming language's motivation & stylistic reasons for choosing certain operators. We're not here to redefine the syntax of R, but just to make it slightly more pleasing (read: legible) to the eye. Replacing !=
with ≠
is not about replacing an arbitrary "is not equal" syntax to ≠
, but about working with the idea that is already captured in !=
, namely that it visually looks somewhat similar to ≠
, and then trying to preserve the original shape somewhat.
There is no logic to the percentage-operator-syntax of R, that is a given; but Fira Code shouldn't try to 'create' this logic out of thin air (and probably upset some R-coders along the way), but rather try to make the syntax R-coders already work this on a day-to-day basis a bit more legible / pleasing to the eye.
There is no logic to the percentage-operator-syntax of R, that is a given; but Fira Code shouldn't try to 'create' this logic out of thin air (and probably upset some R-coders along the way), but rather try to make the syntax R-coders already work this on a day-to-day basis a bit more legible / pleasing to the eye.
Absolutely agree. Your proposal to simply reduce the size of the % signs to de-emphasize them is perfect.
Other ways of de-emphasizing could be proposed of course. The following is a bit whacky (and probably too much), but just as an example of a different presentation that doesn't semanticize, but just re-arranges slightly to create a eye-catching but recognizable version of the original thing.
I like the suggestion of reducing the size of the percentages -- I would suggest though that the circles in the percentages could become individual solid dots (so each percent symbol looks like dot slash dot). To me that seems clearer and less visually noisy, compared to having tiny circles with just a wee bit of white space in the middle.
I also like the suggestion of still turning the >
into the ligature for |>
, for the reasons I gave above. But if folks prefer to leave it more closely resembling the original >
, my suggestion would be to at least stretch it horizontally a bit to suggest the shape of an arrow a bit more, which I think is more suggestive of the symbol's meaning. In fact, we could preserve the original width of the full three-character combination, just shrink the percentages and stretch the greater-than to make up the difference.
Yes, @timgoodman, that's an excellent suggestion, I think it looks good because it's very clean :) And widening the >
does seem like the Fira Code think to do, and it looks good:
I do believe the whole point of Fira Code is to have the ligatures take the same space as the original characters, even though that often means adding more space around a shrunk figure, so yes, that is necessary.
Thanks for illustrating that, @kelleyvanevert. I think I've come around to liking that better than my earlier suggestion based on F#'s ligature. It looks nice and clean, with the emphasis on the meaningful part, but still clearly recognizable to anyone who's seen the magrittr/dplyr pipe.
(Nice. I do think I've shrunk the percentages a bit too much though, displaying the text so big is different than displaying it regular size, where legibility is more of an issue.)
=> What do other people think?
By the way, this would make existing code look something like this:
Where the original would be:
... which makes me think it's not legible enough, and is a bit unclear still. Really, those percentage signs are ugly, man :| Crazy R people.
The @timgoodman suggestion (with the wider > character for the pipe) looks great! I think perhaps with the mini-% signs aligned with the bottom line, rather than centered would be less jarring regarding legibility.
From a quick review of packages, it looks like the following operators are in at least somewhat common use. I don't know how flexible the ligature system is if it could detect a pair of % % separated by an arbitrary number of characters and ligature in all such cases.
From base
%*%
%o%
%in%
%x%
%%
%/%
From tidyverse
and others
%>%
%+%
%@%
%|%
%||%
%T>%
%$%
%<>%
%within%
%m+%
%--%
%+replace%
%??%
%,%
From igraph
%u%
%--%
%->%
%<-%
%c%
%du%
%m%
%s%
From foreach
%:%
%do%
%dopar%
From stringi
%s<%
%s+%
From data.table
%chin%
%inrange%
%like%
%between%
From assertthat
%has_name%
%has_attr%
%has_args%
Others %over% %nin%
Although I really like these ideas of the last few days, do we know if this is technically possible for the creator of this font?
I do think so. I'm not versed in typography and all the crazy opentype features, but it seems that the technique that Fira Code uses is generalizable, and it already includes a 4-character ligature (####). As far as I can tell, it has to do with not just using the normal liga
substitution table, but some kind of quircky method that can generalize.
See gen_calt.clj.
I think out of all the possible options, I prefer the deemphasis of the %
and emphasis of the operator that is contained that @kelleyvanevert introduced. It is also extensible, which is important as new packages begin to create their own binomial operators. I wouldn't want to get in the business of having to custom do ligatures for each iteration of %(╯°□°)╯︵ ┻━┻%
that involves too much deep thinking. Using a ligature that can't be comprehended by a programmer of the language who is unfamiliar with FiraCode
doesn't seem like a good 💡
@robertmitchellv Agreed, the fact that the same approach works for any custom binary operator is definitely a plus.
But now I'm really wanting to think of a good use for the "flip the table over" operator. :)
This preserves the % and the directionality, but also the concept of "pipe" in that it has an opening for the data to flow through.
@jzadra That doesn’t really look like the % at all to me, and there is no indication that a second % is there. Also isn’t extensible to any other % operator.
@bwiernik Pretty sure it was a joke....
I know I haven’t had enough sleep when I miss a phallus in my environment.
We use the pipe operator
%>%
a lot in the Tidyverse set of packages in the R programming language. It's a way of stringing together many functions, converting them from prefix to infix. It would be really nice to have a pipe ligature.