-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow users to define "dot" vectorized operators. #14544
Comments
See #8450. There's more of a desire to get rid of dot-operators and vectorization in general than to add more of them. |
@tkelman after checking #8450, I red this comment from Jeff: #8450 (comment) Paying attention to the next two comments:
I think that my proposal would make a lot of sense now at least with the allowed Unicode operators, ie allow Fragment from the reference in my last comment:
|
You should also watch Jeff's JuliaCon talk for context here. Faster map is imminent, ref #13412. Support in the parser for dot versions of more of the unicode infix operators that don't have existing definitions would probably be considered. Vectorized versions of operators that already operate on collections, not so much. |
@alyst got no response so I'd like to ask Jeff the same question again.
It is a real pain sometimes IMHO, at least with the
I'm talking about generality, If by more you mean everyone of them, fine. If not, then I agree with Jeff not to special case any more. Currently I am able to choose the meaning I want for any allowed Unicode symbol, I just want to be able to have dot operators for every one of such symbols, so I can also do whatever I want with them. I'm not asking to define each one of them in
I don't want this in So with #13412 are dot operators going to disappear? If not, I insist to reconsider this for the sake of consistency.
Now I'm curious about the opinions and needs of any of the other ±447 contributors (which should be/are considered equally?). # not even talk about non contributors. Some of them have already expressed contrary opinions to Jeff's of course. So there has been a need indeed for years now. I'll go look that video now, thanks. |
I can't find whether the proposed implementation #6929 (comment) was ever submitted as a PR.
No one responded to this so I think the answer is effectively "if you submit a PR (or make that change to the existing one) we'd consider it." Consistency in terms of parser behavior is good in principle, if someone wants to implement the change. #13412 may change the performance justification for needing dot-operators as separate syntax, as they could be replaced by |
With all my real and sincere respect to the core developers of Julia and their fantastic work, I think responding something like "That seems reasonable" in that thread would have make sense. Unless the guidelines for contributing explicitly mention "If your idea didn't get feedback, go ahead and implement it". |
People are busy and things fall off the radar, sorry. There are a lot of issues and PR's and only so many person hours going into triage and review. I think adding a single new operator to the parser would be seen as a pretty minor change, adding more for consistency might get more feedback. |
I think we need a general solution to the vectorization issue (#8450). Adding dot versions of each operator won't solve the problem of functions that are not operators. |
I think that with hundreds of symbols to choose from, others surely can have more room for creativity, in your case I have suggested using Also, It's possible to alias a function that is not an operator, with an operator, as shown in #8450: julia> foo(x) = x^2*3x
foo (generic function with 1 method)
julia> ⤇ = map
map (generic function with 39 methods)
julia> foo ⤇ 1:5 # \Mapsto
5-element Array{Int64,1}:
3
24
81
192
375 We could define or alias non operator function with ie, |
I think this can be separated into 2 proposals:
My general, non-committal response is that I just don't think elementwise-ness is that important. I do think it's important enough for My preference is not to have any dot operators, but many of them just have to be there by tradition, like Yes, it's true that I'm fine with having tons of operators available to be defined. However, I think there needs to be some notion of what they might mean, or that they make sense in some way. If we agree to It could be awkward if many, but not all, dot operators are defined in Base. Currently it's a small fixed set, summarized as "the simplest math operators". But if "dot operator" became a more generally-used concept, we'd have the problem of it being hard to guess which are defined. Here's another way to look at it. There are close to zero good standard ways to augment identifier names, like the |
I think it wold be nice if users could define their own dot vectorized operators, some examples are
in
(.in
/.∈
), andis
(.is
/.===
). This is the more julian thing to do IMHO (think of identifiers with a bang alsofoo!
), this would also allow us to use this functions as infix operators, similar to the now vast array of symbols that we can choose from as infix operators for user defined purposes.Refs:
in
operator #5212This would be an easy solution for the user needs (see
DataFramesMeta
suggestion to use a macro within a macro and change non dot operator semantics, when a function would be enough) without having to implement such methods inBase
, selectively add (and debate) such operators for just a few of them (most would never make it intoBase
), instead this proposal would generalize dot vectorized operators into a common julian thing to do.cc @JeffBezanson @StefanKarpinski @nalimilan
The text was updated successfully, but these errors were encountered: