-
-
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
Core.ifelse
calls to avoid invalidations from defining custom Base.ifelse
methods
#46366
Conversation
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. |
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.
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
ifelse
invalidations reported here:SciML/Static.jl#77 (comment)
After this PR: