kotlin-graphics / kotlin-unsigned

unsigned support for Kotlin via boxed types and unsigned operators
MIT License
74 stars 7 forks source link

Provide Mutable and Immutable Utypes #16

Open SerVB opened 6 years ago

SerVB commented 6 years ago

Now we can change var v so even val Utype is mutable. What about renaming currenty Utypes to MutableUtypes (like in Kotlin Notation) and providing Utypes with val that will be truly immutable? I will use those immutable classes.

elect86 commented 6 years ago

The idea behind is that since they are boxed, in this way it is possible to offer a way to avoid a new instantiation.

The thing I dislike about MutableUtypes is the verbosity..

What about using instead some read-only interface? A concept that for example is used by joml

SerVB commented 6 years ago

I've checked joml. Have I understood right that they use a letter c for those immutable interfaces? So the concept is clear for me. It will be great if we have the same logic in the Kotlin Unsigned project.

Now we have to find somebody who will implement it :)

SerVB commented 5 years ago

There are experimental unsigned types in Koltin 1.3. And they support immutability via val... They use new feature called "inline classes" to do this. So I'm going to switch to the official lib. Anyway, thank you for the work.

elect86 commented 5 years ago

Yep, thank you for assisting so far :+1:

Ps: I'm also tempted to switch to the lib, but my biggest problem is that unsigned doesnt extend Number class..

SerVB commented 5 years ago

Actually, my biggest problem now is that the lib doesn't provide toDouble() methods :) I even created an issue: https://youtrack.jetbrains.com/issue/KT-27108 .

elect86 commented 5 years ago

Well, you know you can easily implement that here :p

Anyway, I voted your issue, maybe it'll get implemented sooner or later

I see you also mention the Number inheritance.. actually this might be solved if they change Number from abstract class to interface, but as they write:

no compelling use cases