Add infix "!in" as synonym for ∉ ?
I miss not having infix ni as the opposite of in like Tcl has
∉ is nice, but I don't know how to type that.
I end up with a lot of if !(x in v) ... which I'd rather replace with if x ni v ...
Does this seem crazy to people without a Tcl disorder?
Update: waiting for general infix ! per https://github.com/JuliaLang/julia/issues/15353#issuecomment-192480765 .
?
Sorry @nalimilan I think I pressed enter too soon an submitted a half-typed issue.
∉ can be typed by \notin (both in Atom with the latex plugin and the REPL)
HI @Dawny33, I'm not sure what Atom is. I mostly only ever type code into Vim. I'm sure there is a way to type ∉ in Vim, but I can only fit a finite number of Vim shortcuts in my brain.
I think it's reasonable to expect that non-ascii operators have an ascii-typeable equivalent.
@samoconnor Yeah, the request is quite reasonable :+1:
Just trying to point out the latex shortcut for quick reference!
Does this seem crazy to people without a Tcl disorder?
Yes, I must confess I'm in that camp. :-) Using if/fi and things like that always sounded weird to me. We may as well use out (just joking).
ni is nice because it is reverse("in") and also "not in" and also because Ni!
But if ni is too cute 🐶, then !in or not in or notin would be fine too...
If we really need an ascii infix not-in operator (is !(a in b) not sufficient for most purposes?) then I'd rather have it spelled notin than ni.
@tkelman +1
notin plays well with the latex shortcut \notin, so it avoids unnecessary confusion. And yeah, we need a not in operator, as it is a bit of a frequent usage.
Ni! Ni! Ni!
@KristofferC Icky Icky Icky Ptang
Indeed, the movie reference is the only possible justification of Tcl's choice.
Adding notin(x, itr) = !in(x,itr) to reduce.jl is easy enough.
What has to be changed to make it work as an infix operator?
Clearly, ni should be equivalent to \ni, which is∋-- the left-right swapped version ofin`.
@samoconnor You might want to look at https://github.com/JuliaLang/julia-vim AFAIK it can replace \notin with the appropriate unicode symbol
Perhaps parsing !in as infix would be better, as in a !in b.
+1 for !in as an infix operator.
One reason to prefer notin is that it's compatible with allowing all functions to use infix syntax, while !in would continue to be a special case even if we made that change.
If a foo b desugars to foo(a,b) then a !foo b could generically desugar to !foo(a,b). On the other hand, I find this particular syntax issue to be mild enough that it can wait.
Could be useful, but we'll have to wait until more infix operators are supported to really give !in that general meaning. Until then, it will only be a weird exception.
If it is agreed that a general infix ! and !in can wait, then notin seems to be broadly agreeable.
Would a PR for notin be welcome?
I'm against it because then we'd have to deprecate notin when !in happens. In the meantime, writing !(a in b) is not so awful.
Fair enough.
Now have !in
Does it also solve https://github.com/JuliaLang/julia/issues/25512, or does it only work for in?
But x !in y doesn't work, right? Yet that's what this issue is about.
Yeah, sorry, I missed the actual point here.
I think people are upset that you have to write !in(2, [2,3]) but can't write 2 !in [2,3]
Allowing ! before infix word operators (in, isa) seems like it would ok to me. However it's slightly dangerous territory since by analogy if a !in b means !(a in b) then one would expect that a !== b to mean !(a == b) but it actually means !(a === b).
maybe disallow !== say ambiguity error?