-
Notifications
You must be signed in to change notification settings - Fork 156
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
Support for const types #76
Comments
I can't do this across the board because the intrinsics that glam uses are not const fn. I'm a bit reluctant to do it to some types and not others because it would be inconsistent which could be confusing. As soon as intrinsics get const fn I would be keen to use it. In the interim you could use an array or tuple are truly in the into/from implementations. |
I guess I could do some union hacks to avoid calling the intrinsic functions. Last time I played around with doing that it was a bit of a perf hit so it might not pan out, should be possible though. |
It's definitely not a pressing issue. I can easily work around it. I really like glam for its simplicity and uniformity. Just wanted to check whether this was an oversight or a limitation. :) Feel free to close this issue as you see fit. |
No worries, it's something I would like to address. Will leave this open and try out the union cast thing some time. |
I tried this out but unfortunately performing union casts and other unsafe casts is not allowed in It might be a while until Rust gets that feature but I'll leave this open for now anyway. |
Rather than making operations |
That is what I was attempting to do. The simd types like __m128 are opaque and you need to call functions like _mm_set_ps to initialise them. Those functions are not const. I don't know if there's any reason those std lib intrinsic functions couldn't be made const though. |
Oh, ok. |
I raised an issue with |
It looks like it should be possible to make the constructors in In the interim I've added a bunch of macros that can be used to create Internally these perform a union cast which is allowed for This is just in git for now, at some point I'll make a new release to crates.io. I still need to write some docs and make some other changes. Let me know if you try them out. |
I would also be grateful to see some more utility functions for vectors made const where possible, such as |
@alice-i-cecile I don't believe that's possible right now either. Floating point arithmetic is not allowed in a |
Darn, that's fair enough. I'll keep my eyes on that issue too then. |
Is it possible to make just the |
Not at the moment, see #76 (comment) |
::new shouldn't be doing arithmetic though, right? |
It does not, as the comment above says, the SSE init method is not const fun. This needs to be addressed in the std library |
Ohhhhh, I see, thanks. |
@SkiFire13 pointed out unions can be used in a const eval context now so this issue is finally resolved as part of #294. |
Currently, constant types don't seem to be supported:
I can't construct the tuple manually either, since there is only crate-level visibility. Would it be possible to implement this?
The text was updated successfully, but these errors were encountered: