-
Notifications
You must be signed in to change notification settings - Fork 23
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
Key word for dimensionally unsafe actions #20
Comments
I can't think of something better than unsafe. I think unsafe is sometimes used in rust even when memory safety is not at issue (but only correctness). I think that bypassing compile-time guarantees could qualify as unsafe. e.g. interpreting a 32-bit integer as a f32 is unsafe, even though it cannot lead to any memory corruption issues. It's only unsafe because it might give different answers on different architectures. But broadly speaking, dimensioned is preventing precisely the same kind of thing: accidentally treating a value as a different type of value. |
Unsafe it is! |
Rust's I do not feel there needs to be a single term for this applicable in all contexts; one could call the member Re: integers to floats, |
Reopening this issue to be considered for the next batch of breaking changes (which will likely be when const generics are a thing). |
I would like to ensure that any interface that lets you take actions where units are not checked is clearly labeled.
For example, in v0.5 of dimensioned, there is a
map
function that lets you apply a function to the underlying value. In the rewrite, I am looking at having two functions,map
andmap_unsafe
. Both do the same thing, but the newmap
is only defined when dealing with dimensionless quantities so you have no units to mess up.I would like direct exposure to the underlying value to follow a similar naming convention, but the word "unsafe" has pretty clear memory-safety connotations in the Rust ecosystem and I would like to avoid it.
Thoughts?
The text was updated successfully, but these errors were encountered: