-
-
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
Add docstring to promote_op
#25689
Add docstring to promote_op
#25689
Conversation
base/promotion.jl
Outdated
|
||
!!! warning | ||
In pathological cases, the type returned by `promote_op(f, argtypes...)` may not even | ||
be a supertype of the return value of `f(::argtypes...)`. Therfore, `promote_op` should |
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 assume this is due to _default_type
? Unfortunate...
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.
Also typo in Therfore
I guess my main objection is that we do use it for preallocation of an output arrays (e.g. in matrix multiplication): is this unavoidable, or are there known safe cases? Also, how does it differ from just calling |
b350f0f
to
38c8a89
Compare
I guess neither. It is just way simpler than an efficient implementation of the alternative (basing the type on the actual elements). In addition to the empty case, I think I have found one more case where we have a lack of better alternatives: lazy views. What should the element type of an
julia> Base._return_type(*, Tuple{Signed, Signed})
Any
julia> Base.promote_op(*, Signed, Signed)
Signed
|
Just to note that I have exactly the same issue in Query.jl. You can think of the design there as a series of chained, lazy iterators, and the only way to know what the element type of the last one in that chain is, is to rely on inference. I'm doing away with this right now, but the downside is that |
This function really is hard to justify. |
|
While I certainly share the aversion against Anyway, I've fixed the typo Jeff pointed out, there were no other objections, so here we go. |
The Masters office. Behind his desk, The Master is deeply concentrated, working in front of his computer. |
This should be the |
That tops |
Closes #25609.