Not at all. Just \
will drive me crazy. I always confused it with /
. Furthermore, at least three keystrokes (autocomplete considered) are needed to type the left arrow. Maybe you have a better way?
I am more interested to see a well designed operator for explicitly carrying out float number comparison.
If â
isnât good enough then letâs talk about it (in a separate thread please).
I was kidding, hence the winking emoji.
I know Julia is not going to change, and I do not expect it to.
I learned Pascal early on (on punched cards) The assignment operator is :=
I still think âbecomes equal toâ when writing code
The comparison operator could be ?=
I would read that as âquery equalsâ
If itâs been 20 years, how much sleep do I need?
Perhaps alternate back and forth between an hour of programming and an hour of deep, meditative trance.
One style I have seen to reduce the problem is to flip the sides of the equality test. That often places something that cannot be assigned to and gives an error.
julia> a = 20
20
julia> 0 == a
false
julia> 0 = a
ERROR: syntax: invalid assignment location "0" around REPL[3]:1
Shoot, usually âtry turning it off and on againâ is enough to fix these things, Iâm out of ideas!
To join the bikeshed, I think linter integration into IDEs will be the most value for effort mitigation for this. Maybe JET.jl can handle it - try it out!
Every LanguageServer.jl compatible editor already emits a warning in this case, as demonstrated upthread.
Ah, I think I just scrolled past that. Awesome!
My brain is hard-wired against =
copying by reference.
Why do we need to use copy()
every time we want to copy the content of an object.
I think most of the time users want to copy the content, not create references.
=
should be the default way to copy object content.
The unfortunate thing is that negation has become inconsistent because of this choice. The negation of most operations are
!<op>
but the negation of ==
is !=
. And this is blocking a feature Iâd really like to see: ! for infix operators ¡ Issue #25512 ¡ JuliaLang/julia ¡ GitHub
A possible way out would be to have !==
and !===
, but they would be really long. Also, itâs of course never going to happen.
Assignment as :=
would be wonderful, and not too long at all.
What about using espanso or just remap a key (that you donât press with your pinky) to input == ?
I usually think similarly, but not in Julia where Iâve gotten used to another way of doing things. My experience with Matlab made me very happy with copy-on-write, but now Instead of
b = copy(a)
b[someelement] = newvalue
Iâve gradually learned to copy and mutate simultaneously, e.g. using map
, generators, and broadcasting. Quick anonymous functions make this easy. I donât even do much piping |>
but that can even be more concise. Itâs nice to borrow some approaches from functional programming without having to go all the way.
Yes, those are called Yoda Conditions and were mentioned before in this thread.
Hi blackeneth,
People do seem to have strange names on the internet. Anyway, I was just wondering how old you are? Iâm 68 and this really isnât a big problem. There are many languages that do the same thing, itâs not special to Julia.
I can offer you a simple suggestion which may help. PostIt notes, just stick one to your monitor with:
= for assignment
== for test
After a while, Iâm sure you will break your habit. Itâs like most things âpractice makes perfectâ or in this case âimproves your memoryâ. But, one thing that wonât help is to get overstressed by it. Relax, have a drink and just go âoops did it again no big dealâ.
Kindest regards
Jeremy
I dislike â in R almost as much as I do := in PascalâŚ
I agree: â==â is an abomination upon mankind. I once spent six months trying to find why an error recovery routine blew up in a C program. It was because a programmer had written âif (a = b) { ⌠}â which always resolved as true.
I canât tell you how many times I looked at that code and saw what I thought rather than what was actually being done.