Core.ifelse calls to avoid invalidations from defining custom Base.ifelse methods#46366
Core.ifelse calls to avoid invalidations from defining custom Base.ifelse methods#46366chriselrod wants to merge 1 commit intoJuliaLang:masterfrom
Core.ifelse calls to avoid invalidations from defining custom Base.ifelse methods#46366Conversation
|
Alternatively, I could call |
|
Neither of these approaches seem great, but there might not be a better solution. |
|
Perhaps I should do This breaks things returning |
|
Thanks for taking the lead on this. I looked at it and wasn't sure what the best path forward was. It seems like we shouldn't have this much trouble inferring |
3307d66 to
fa2e78b
Compare
fa2e78b to
0aba774
Compare
|
Jeff suggested |
The trouble is we don't have a way to enforce types like |
ifelse methodsBase.ifelse methods
Base.ifelse methodsCore.ifelse calls to avoid invalidations from defining custom Base.ifelse methods
That would be nice. |
aviatesk
left a comment
There was a problem hiding this comment.
It sounds reasonable to use Core.ifelse in place of ifelse(c, x, y) where the types of c/x/y are known to be such types that are owned by Base, but otherwise it sounds against Julia's design pattern.
E.g. max(x, y) = Core.ifelse(isless(y, x), x, y) disallows the possibility to overload Base.ifelse(c, x::S, y::T) to customize max(::S, ::T)/min(::S, ::T), where S and T are owned by users.
But it seems reasonable to me to define max(x::Float64, y::Float64) = Core.ifelse(isless(y, x), x, y) as users aren't supposed to override the definitions of isless and ifelse for Float64 types.
On the other hand, you probably shouldn't rely on overloading |
IIRC, the reason I kind of agree that we can (maybe should) revert overloading |
Addresses
ifelseinvalidations reported here:SciML/Static.jl#77 (comment)
After this PR: