-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
RFC: Optional explicit return type for map and broadcast #6547
Conversation
MikeInnes
commented
Apr 16, 2014
It would be good if could make this work for the function returned by |
@toivoh How's that? |
i feel like this (wanting to add an explicit return type to a function) is a frequent enough pattern that it deserves special syntax, so I opened #6551 |
The usage of
which should give an equivalent result to As I understand it, this PR allows Also, shouldn't you use |
Another thing to note is that the suggested overloading would be very close to ambiguous in some cases. You can I agree with @vtjnash wanting to specify the resulting element type is a common pattern, and it would be great to have a common convention for it, but I'm not sure if introducing syntax like in #6551 is worth it. Also, To me, it would seem ideal if we could have a convention for a named argument, like |
This actually works with no changes, since const broadcast_f = broadcast_function(x->x^2)
broadcast_f([1,2,3]) => [1, 4, 9]
broadcast_f(Float64, [1,2,3]) => [1.0, 4.0, 9.0] (you're right about using Mapping over tuples of types definitely seems like an uncommon edge case. A keyword argument would do the job for map, but they aren't supported by anonymous functions (yet). Personally I'd be happy to leave it as a caveat that if you want to do this, you just have to specify return type, but another option would be to have a |
Hmm, that seems to defeat the whole purpose of |
I'm not sure Perhaps problems with Thinking about it, named arguments won't work: this version of |
6c7c7e3
to
1a4c02f
Compare
Looks like there's no interest in this (and/or other approaches are in the works) so I'll close. |