First, you cannot force other people to like what you like. Even if this new syntax was accepted into Julia source code, most library maintainers would still not accept PRs with unicode (i.e. non-ASCII) characters.
Second, if you are the only one in the world who uses a different syntax, that DOES NOT make you creepy. Today is Pride Day, the best day to remember that being different is not creepy, not weird nor sinful. It is also the day to remember that people have different tastes and opinions. Diversity is a good thing.
In short, if you want to use a different syntax, use it. The option is already on the table. If other people adopt it, that’s great, otherwise, that’s okay, too.
Sure, but suggestion was to treat the ligature as alias: ⩵ and ==, which is not currently the case (I’ll edit my post to clarify). It’s great that the ligature(s) are available in multiple fonts, so why not build them in? (As others have noted, this could/should be implemented in a package, which would make it convenient to test out.)
The documentation says to * Users should refer to LineEdit.jl to discover the available actions on key input.*
This file can be found in julia/share/stdlib/v1.6/REPL/src
LineEdit.jl is a 2563 line program written by someone obviously very skilled in writing a character interface.
The “available actions” appear to start at line 238. “:edit_insert” looks promising. Search for “edit_insert” and you find the function edit_insert() at line 736.
At that point, function edit_insert() is incomprehensible to me.
So, let’s try guessing (if you consider this to be a bad method, you would be correct):
This does not work:
import REPL
import REPL.LineEdit
const mykeys = Dict{Any,Any}(
# \ie[tab] to ==
"\\ie" => (s,o...)->(LineEdit.edit_insert, s, "==")
)
function customize_keys(repl)
repl.interface = REPL.setup_interface(repl; extra_repl_keymap = mykeys)
end
atreplinit(customize_keys)
In fact, executing the above in your startup.jl will prevent you from typing the letter “e”.
You can’t type exit() to get out.
It took me about two hours to come up with that guess (it is in fact guess version 4, the first three were worse).
If after a while you get a bunch of users, revive this topic: you will be in a much better position to argue for it.
That’s just erecting a marketing barrier to the proposal. Say I create a “package” (consisting of one line of code). Users may love it, but if they don’t know about it, they can’t benefit from it. Package popularly then depends on how well it is marketed to the user base, not on how much user benefit comes from it.
Package popularity is also not always indicative of a change you would want to make. Say I marketed the brilliantTwoBasedIndexing package and got 10,000 users to implement and use it. Would that convince you to finally implement two-based indexing into Julia and replace “obsolete one-based indexing to proper two-based indexing”?
I think we are talking past each other. The programming language has nothing to do with this, and you don’t have to ‘treat’ anything as an alias, because it’s just one ‘thing’.
When a font supports ligatures it means that it just displays a character combination in a certain way, without changing the underlying representation. There’s no need for a Julia package, it’s handled entirely by the font itself, plus the editor, which needs to support it, and this is not the case for the REPL – is that what you are referring to?
I mean, this already exists and works for VS Code and Sublime Text, at least, probably more. The fonts just need to introduce a ligature for ==. Julia doesn’t need to do anything at all.
Update: It seems that Fira Code, does already, but not JuliaMono. I’m not sure if this is distinctive enough, though:
Ah, thanks for the explanation. I was in Monaco font in terminal REPL. I’ve installed Fira Code (and “Use ligatures” in iTerm2) and can verify that it does do the ligature properly, and still treats (e.g. copies) it as two equals chars ==.
The ligature is a neat editor feature, but I think it is still different from REPL. With ligatures turned off, I can type \ge to get ≥ which I believe to be an alias for >=, that also looks distinctly different from the Fira Code ligature. For consistency, I’d be in favor of REPL treating \Equal as alias for ==. The issue isn’t the input, it’s the treatment.
Not that anybody cares, but Mathematica does it a slightly different way, because you type two characters -> and copy just one →.
but people don’t write Mathematica over ssh on vi, you can do whatever you want, Julia has support for you:
julia> const ⩵ = ==
or you can open a PR to add this alias, or just use a font with ligatures. It’s all up to you, but please don’t open two thousands PR later to add this and change every == to ⩵ across all julia rpeo (semi-jokingly
Yes, ≥ is a unicode character which is separate from >=, while the font ligatures are just a display effect, and keeps the underlying characters unchanged, so when someone else looks at my code, they cannot tell if I have used ligatures or not.
Whether or not ≥ is an alias for >= is entirely up to Julia, while font ligatures are completely not.
I think that ⩵ should be an alias for ==, not for the reasons mentioned above, but simply because it would discourage people from making it an alias for something else.
You can find the completion engine in stdlib/REPL/src/REPLCompletions.jl. Currently it assumes that completions starting with a \ character are either LaTeX or (if starting with \:) emojis. So a proper implementation would require a refactoring, but for a quick test you can add a “LaTeX” completion:
Some say this would be a breaking change since some modules might already be using ⩵ for other purposes, but couldn’t this problem be solved (and thus have a whole consistent group of single-character Unicode operators) by temporarily adding a warning when this symbol is currently used not as an alias for ==? Same for ⩶, while we’re at it!
Objection: It’s just one of many common errors @oheil replied:
There are a lot of common errors. E.g. forgetting ; at the end of a line, forgetting a closing " at the end of a string, using ' instead of " for strings, just to name a few which come to mind for this and other languages.
Response: Not quite the same.
That’s not really the argument I would make. I think it’s exactly the same – and fixing common mistakes like thesse is a good idea. Julia has already fixed the problem of ; by assuming a new line of code is, well, a new line. This despite adding semicolons not being that difficult; sure, but why make it harder? (' vs " has a useful role – a single character is different from a string, and in a typed language like Julia this can be a useful distinction from time to time. On the other hand, there’s nothing useful that =? or ≟ are doing at the moment – there’s no cost to aliasing them to isequal, and they’d clearly be popular among at least a handful of programmers.)