-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
λ to indicate anonymous functions #124
Comments
Might be difficult, since |
Where does \ appear on its own without an additional character and does not mean an anonymous function? |
Mainly in strings. I don't know if that would count as "on its own", but this is an anonymous function
and this is a newline
and I don't know if it is possible for a font to differentiate between these cases? Maybe we just ignore that case and make a ligature out of backslash followed by whitespace? |
Sorry to jump in, but wouldn't it be incorrect? Lambdas' definitions will usually follow the |
Yes, most of the time people won't have a whitespace between |
No, I think your worries are reasonably founded. |
Well, the language can differentiate between strings and operators, while idk what Haskling can do. Is it possible to make an exception for \n? That would only disallow the anonymous function with the variable name n, all other cases could be covered. |
I would like to add, that /n for a varible name that comes after a lambda, would be confusing. \n kinda indicates a newline, if within a string or not, so this is a bit 'bad style' and is advised to be avoided anyway. So if we can avoid \n for that reason, is there anything else that could be considered? |
I would like to add, that /n for a varible name that comes after a lambda, would be confusing.
\n kinda indicates a newline, if within a string or not, so this is kinda bad style.
No, I disagree. `n` is a common variable name, regardless of if it is used in a lambda or not. Furthermore, we would have to disqualify any name starting with n as well and that is starting to get ridiculous.
So if we can avoid \n for that reason, is there anything else that could be considered?
Yes, \t, \x1234, \r, \\ and probably a few more I have forgot about.
I am starting to think that, unless the font can render differently in strings and outside strings, the easiest way to implement this is to simply accept that escape codes in strings get rendered as lambdas, despite it being kind of wrong.
|
Yeah, I would fully agree on that |
I did a little bit of research, and according to Tonksy, who is the developer of the contextual alternative code, which is used in Hasklig, is this possible to differentiate between comments and functions via the syntax highlighting. tonsky/FiraCode#1207 (comment) So you can turn ligatures off in comments, which is sensical anyway, in my opinion. |
(and in strings) Sweet! |
So can we do this now? 😄 |
\ is meant to indicate a λ
I know this is a little bit of a stretch since it is one character, that is converted into a ligature and not two.
But I think it is worth thinking about this since it makes the language prettier and it makes the symbol more clear in its intention.
Thanks a lot to consider this ☺
The text was updated successfully, but these errors were encountered: