-
-
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 user-defined functors to be passed to more methods in Base #12035
Conversation
What are the places left that uses |
Only in |
@@ -189,7 +189,7 @@ copy(x::Union{Symbol,Number,AbstractString,Function,Tuple,LambdaStaticData, | |||
TopNode,QuoteNode,DataType,Union}) = x | |||
|
|||
# function pipelining | |||
|>(x, f::Callable) = f(x) | |||
|>(x, f) = f(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this conflict with the deprecated piping of Cmd
objects via |>
? I don't think we can make this change until after that deprecation gets removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, since Cmd piping will still invoke the more specific |>(src::Base.AbstractCmd, dest::Base.AbstractCmd)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm okay, well if no ambiguities then I guess we can see what happens
I guess the |
Maybe it's best to just change the |
Agreed, now that everything is potentially callable, we should get rid of |
What should we do about the ambiguity that will exist between |
Perhaps change the name of the first? On Thursday, July 9, 2015, Jonathan Malmaud notifications@github.com
|
OTOH, restricting these methods to |
Given that we don't have multiple inheritance, that would be a rather extreme constraint on type hierarchies. Much better to ditch |
Would this be a case where "Holy" Traits could come to the rescue? |
Yeah, actually I had in mind a kind of a trait (which the name |
I strongly disagree that using a trait here is a good API. |
@yuyichao Could you elaborate please? |
It seems |
What about inserting a deprecation now and having it call a function of a new name? Otherwise you're stuck with it through 0.5, too. |
Long ago I proposed a |
+1
|
I think that syntax is fine, but I don't see how it solves the |
@timholy You're proposing introducing a new function that implements the behavior that |
Yeah. It's basically the same thing that @kmsquire was saying, I think. |
I envision making |
Seems like it could be a bit janky: I have a callable object |
Feels like #5571 (a little bit). In any case, should we merge the non-ambigious part of this PR? |
@@ -186,7 +186,7 @@ sum_pairwise_blocksize(::Abs2Fun) = 4096 | |||
mapreduce_impl(f, op::AddFun, A::AbstractArray, ifirst::Int, ilast::Int) = | |||
mapreduce_pairwise_impl(f, op, A, ifirst, ilast, sum_pairwise_blocksize(f)) | |||
|
|||
sum(f::Union{Callable,Func{1}}, a) = mapreduce(f, AddFun(), a) | |||
sum(f, a) = mapreduce(f, AddFun(), a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems weird to me, given the existence of sum(array, dims)
. I think ideally this definition would not exist at all.
count
is ok, since its first argument is always a function.
Fixed on master. |
Closes #12012