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

Any chance you will be adding some kotlin convenience code? #19

Open
xGnoSiSx opened this issue Sep 1, 2021 · 3 comments
Open

Any chance you will be adding some kotlin convenience code? #19

xGnoSiSx opened this issue Sep 1, 2021 · 3 comments

Comments

@xGnoSiSx
Copy link

xGnoSiSx commented Sep 1, 2021

Any chance you will be adding some kotlin convenience code?

@terzerm
Copy link
Member

terzerm commented Sep 1, 2021

Thanks for your question. We have not currently planned any such activities.
Can you elaborate a bit more as to which part of the library you would like to be made available in a more convenient way, e.g. with some pseudo code examples?

@xGnoSiSx
Copy link
Author

xGnoSiSx commented Sep 1, 2021

Hi,

Very simple: Operator overloading. Kotlin allows you to define functions with special names to make it possible to define natural mathematical operatos on custom types:
Kotlin reference

This includes, comparison, unary, binary, and augmented assignment operators.

I just picked up this library and will probably be writting those as inline extension helpers for Decimal3f, without changing the library.
Extensions

I can send/upload those, for that datatype and you can just copy/paste and replace for the other types.

Example:

inline fun Decimal3f.plus(b : Decimal3f) : Decimal3f { 
    return this.add(b)
}

And after that, you can write:

var result: Decimal3f = a + b + c + d

You could also add helper extensions for Longs, but these could get tricky.

@xGnoSiSx
Copy link
Author

xGnoSiSx commented Sep 1, 2021

There's also increment operators, but may be difficult to decide the increment step. I'd assume by 1 but others might think that's wrong. You could leave that up for users to define.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants