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

Full support for units.net features? #26

Open
eddiesholl opened this issue Nov 3, 2023 · 2 comments
Open

Full support for units.net features? #26

eddiesholl opened this issue Nov 3, 2023 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@eddiesholl
Copy link

Hey there,

Stumbled on this library recently, for what it offers it’s a great API. I was wondering if you’d looked into the possibility of a full replication of units.net? An example of what might be possible, is cross conversion of units when you multiply and divide, so length.mul(anotherLength) returns an area, that sort of thing.

looking in the original repo, it’s all driven by even more codegen than is used here. I was just wondering if you’d already looked into what that whole task would look like, and if it would even work.

not sure if typescript method overloading would allow this sort of thing, for example.

That full API, where units are tracked for you in a type safe way, would be pretty freakin cool, I think.

thanks!

@haimkastner
Copy link
Owner

Hi @eddiesholl

Thanks for your comment.

I haven't yet thought much about how to design it, need to find some extra time for it :)

However, JavaScript (and TypeScript) is missing important and complex features compared to the strong-typed C#.

For instance, there is no way to overload operations, which forces operations implementation to be something like: unit1.add(unit2) instead of unit1 + unit2 which looks and feels way better, and I guess similar problems may come up in the implementation of other original library features.

Specific to your example with cross conversions, TypeScript does support abstract classes, so it should be possible to implement.

Did you already have some specific design in your mind?

@eddiesholl
Copy link
Author

No nothing yet, I was more trying to think ahead to how much more could be possible. I’ll let you know if I get some time to try anything out

@haimkastner haimkastner added enhancement New feature or request question Further information is requested labels Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants