-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Un-breaking functions requiring <:Real
#66
Comments
We didn't subtype The problem with having an independent type hierarchy is that we get a large decrease in load time b/c we can pool a bunch of definitions under Or maybe I haven't slept in 36 hours and that's just a bad idea. |
Thanks @Tokazama . I still think support for this should just go into Base. We already have type-level support for irrationals that seems to work very well. As I understand, the argument for having type-level support for irrationals is that it seems to work well, and the argument against having this for any other numbers is that people would use it in weird ways. But people will use anything in weird ways, there's no stopping it. So it's best IMO to add support together with some guidelines for proper use. Short of that, I understand these issues are very tough to work through. And it's not pressing anyway, I can just stay with 0.6 until there's a solution. For now it's more important for you to get some sleep :) |
Is this I'm a little baffled that |
Yes, the current case I'm hitting is MethodError: no method matching exp(::Type{LogarithmicNumbers.ULogarithmic}, ::Static.StaticFloat64{0.0}) But I think constraining an argument to be
Me too. Some devs seem pretty type-averse in general, which is kind of foreign to me. I think it was a mistake to have |
Couldn't it be argued that using a subtype of If there is a practical reason for the restriction then I'll have to think about it more. There may not be an easy solution.
I get why things are the way they are. We had to start somewhere. But it feels like I'd have to rewrite a bunch of internal stuff in base to make it clear how useful this paradigm shift would be to some, and that sort of wide-sweeping change is not really how we're supposed to make collaborative improvements in software development. |
Slightly unrelated, but IMO the situation with irrationals is far from optimal. Defining them outside of base is always type piracy and was not intended by the original authors (as far as I understand). Additionally, promotion is a mess and can lead to surprising/undesired results. |
I think people often do this when something won't work for complex values. As I understand, best practice is to use type constraints for dispatch and not for restricting the domain of a function, but you still see it all over the place.
Yes of course, and it's also easy to forgive occasional weirdness like this when so many other design choices are really solid.
Could there be a smaller version of this? Outside of Base, ignoring load times, ignoring type piracy concerns, not as part of a package but just to demonstrate what's possible?
Thanks David. I'd never thought about defining new irrationals - you're right that it's type piracy, because it defines a Base function on The promotion issue is less clear to me. |
I was thinking about behaviour such as the one described just yesterday on Slack (https://julialang.slack.com/archives/C67910KEH/p1655450699891149): julia> typeof(-pi*1.0f0)
Float64
julia> typeof(pi*1.0f0)
Float32
julia> typeof(-pi)
Float64 |
Good example, ouch |
@cscherrer, is this still very problematic for you? We discussed what it might look like to pull out |
Thanks @Tokazama . Yes, we currently can't upgrade to 0.7 because so many functions in other packages want arguments |
The move to |
Is indexing arrays with |
Currently no. I guess it's not really indexing - more about representing array sizes. Static sizing doesn't seem very clean yet, for example something like a Cholesky factorization can end up with the size information buried deep in the types. So it's still not clear to me yet what the interactions look like between Static.jl, StaticArrays.jl, and ArrayInterface.jl. Anyway, that's really more of a side question. If 0.7's approach to StaticInts works well for you it will probably be fine for me too. |
If you're confident that it would be helpful, then I'd be happy to review/assist in getting something like StaticFloat.jl going (I can't personally take that one on at this time). I mostly want to make sure that your concerns were addressed after https://discourse.julialang.org/t/static-jl-vs-staticnumbers-jl/87228. |
Thanks @Tokazama . I don't have a sense if there might be a lot more to this than I can see, but I'll take a stab at it. It will be https://github.com/cscherrer/StaticFloats.jl - I'm modifying a fork now so we can keep the Git history as accurate as possible. |
Now that
StaticFloat64 <: Real
is false, lots of functions that are defined independently of Static.jl are breaking. More concretely, supposeis defined in a package that does not depend on Static.jl. Passing a
StaticFloat64
tofoo
now throws anMethodError
.For packages I control, there's an easy fix: Change the constraint to
::Number
or remove it altogether. But what's the recommended approach for packages I can't change so easily?The only easy fix I see is to define a local
_foo(x) = foo(x)
, add a method_foo(::StaticFloat64{x}) where {x}
, and then always call_foo
. But that seems like a mess, and it will still break downstream when users of my package try to callfoo
. Any other ideas?The text was updated successfully, but these errors were encountered: