Skip to content
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

Add support for integral types as the underlying storage type #29

Closed
iliekturtles opened this issue May 17, 2017 · 6 comments
Closed

Add support for integral types as the underlying storage type #29

iliekturtles opened this issue May 17, 2017 · 6 comments

Comments

@iliekturtles
Copy link
Owner

Add support for integral types (i8, u8, i16, u16, i32, u32, i64, u64, usize? isize?, i128, u128) as the underlying storage type so that users can create new systems which do not use a floating point type. Use features to control code generation. Not all methods may be applicable. Types shouldn't be implemented for the ISQ.

@iliekturtles
Copy link
Owner Author

Use traits from the num crate instead of explicitly implementing each type?

@radix
Copy link
Contributor

radix commented Jul 30, 2017

I use a bunch of integers in my code now, and that's why I'm not using uom yet. I think the num crate is a great idea for this. Note that it also has traits for floating point numbers which would allow you to generalize your float storage backends too (maybe?).

@iliekturtles
Copy link
Owner Author

I'm planning to start work on this issue after #3. I have a proof of concept for that issue but I've been pretty busy with summer activities. I haven't taken a look yet, but my understanding of num is that I should be able to completely generalize the underlying storage type. The only thing I'm not quite sure how to handle yet is the literal conversion factors.

If your code is open source I'd love to take a look when I start in on this issue to make sure a num trait-based solution works.

@radix
Copy link
Contributor

radix commented Jul 31, 2017

Hi @iliekturtles ! Yep, my code is open source, but it's pretty embarrassing with respect to its handling units now. The project is P&T and I have, for example, types like a Distance type which just stores centimeters as a u32 and Point3 as a three-tuple of i16s (meters). Of course the fact that these representations and methods are embarrassing is why I want to switch to uom :)

You can consider it basically like a representation of a board-game or something like minecraft, with positions in discrete blocks. That's why I'm using integers. Most data can deal with integral meters, and occassionally I drop down to centimeters for certain things (especially dealing with lines drawn at an angle, but I still don't need anything more precise than a cm).

iliekturtles added a commit that referenced this issue Oct 15, 2017
usize, u8, u16, u32, u64, u128 (unstable), isize, i8, i16, i32, i64,
i128 (unstable), bigint, biguint, rational, rational32, rational64,
bigrational, f32, f64. All stable types are enabled by default but not yet
implemented. Part of #29.
iliekturtles added a commit that referenced this issue Oct 15, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Oct 29, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Nov 5, 2017
usize, u8, u16, u32, u64, u128 (unstable), isize, i8, i16, i32, i64,
i128 (unstable), bigint, biguint, rational, rational32, rational64,
bigrational, f32, f64. Only f32 and f64 are enabled by default for
compile time reasons. All other types are not yet implemented. Part
of #29.
iliekturtles added a commit that referenced this issue Nov 5, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Nov 5, 2017
Introduces a number of new traits to control how conversion factors are
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Nov 19, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Nov 19, 2017
stored for each different underlying storage type. Part of #29.
@radix
Copy link
Contributor

radix commented Nov 21, 2017

I just want to say that I've been following your development with interest and I'm very grateful that you're doing it :)

@iliekturtles
Copy link
Owner Author

Thanks for the positive feedback! I'm getting really close now. I just need to get all the tests passing. Once that is done I'm planning to put together a PR to replace Distance.

iliekturtles added a commit that referenced this issue Nov 22, 2017
usize, u8, u16, u32, u64, u128 (unstable), isize, i8, i16, i32, i64,
i128 (unstable), bigint, biguint, rational, rational32, rational64,
bigrational, f32, f64. Only f32 and f64 are enabled by default for
compile time reasons. All other types are not yet implemented. Part
of #29.
iliekturtles added a commit that referenced this issue Nov 22, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Nov 22, 2017
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Nov 26, 2017
Introduces a number of new traits to control how conversion factors are
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Dec 15, 2017
Generated test system macros no longer collide with generated macros
from `uom::si`. Part of #29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
Introduces a number of new traits to control how conversion factors are
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
Explicit implementations allow for a literal left hand side. Part of #29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
Generated test system macros no longer collide with generated macros
from `uom::si`. Part of #29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
Handles equality and approximate equality for all underlying storage
types. Tests don't need to be type specific or include approximation
logic for floating point numbers. Part of #29.
iliekturtles added a commit that referenced this issue Dec 17, 2017
All `quickcheck` tests accept `A<V>` as parameters and `deref` into the
underling storage type. Allows for `quickcheck` tests for types that
don't implement `Arbitrary` by default. Part of #29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
Introduces a number of new traits to control how conversion factors are
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
Explicit implementations allow for a literal left hand side. Part of #29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
Generated test system macros no longer collide with generated macros
from `uom::si`. Part of #29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
Handles equality and approximate equality for all underlying storage
types. Tests don't need to be type specific or include approximation
logic for floating point numbers. Part of #29.
iliekturtles added a commit that referenced this issue Dec 18, 2017
All `quickcheck` tests accept `A<V>` as parameters and `deref` into the
underling storage type. Allows for `quickcheck` tests for types that
don't implement `Arbitrary` by default. Part of #29.
iliekturtles added a commit that referenced this issue Dec 20, 2017
Handles equality and approximate equality for all underlying storage
types. Tests don't need to be type specific or include approximation
logic for floating point numbers. Part of #29.
iliekturtles added a commit that referenced this issue Dec 20, 2017
All `quickcheck` tests accept `A<V>` as parameters and `deref` into the
underling storage type. Allows for `quickcheck` tests for types that
don't implement `Arbitrary` by default. Part of #29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
All macros now organized in separate files. `storage_types!` allows for
code that explicitly references an underlying storage type, `V`. Part of
#29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
Introduces a number of new traits to control how conversion factors are
stored for each different underlying storage type. Part of #29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
Explicit implementations allow for a literal left hand side. Part of #29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
Generated test system macros no longer collide with generated macros
from `uom::si`. Part of #29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
Handles equality and approximate equality for all underlying storage
types. Tests don't need to be type specific or include approximation
logic for floating point numbers. Part of #29.
iliekturtles added a commit that referenced this issue Dec 21, 2017
All `quickcheck` tests accept `A<V>` as parameters and `deref` into the
underling storage type. Allows for `quickcheck` tests for types that
don't implement `Arbitrary` by default. Part of #29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants