kotlin-unsigned icon indicating copy to clipboard operation
kotlin-unsigned copied to clipboard

Provide Mutable and Immutable Utypes

Open SerVB opened this issue 6 years ago • 6 comments

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.

SerVB avatar Jul 10 '18 11:07 SerVB

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

elect86 avatar Jul 10 '18 13:07 elect86

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 avatar Jul 14 '18 12:07 SerVB

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.

SerVB avatar Sep 25 '18 10:09 SerVB

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..

elect86 avatar Sep 26 '18 06:09 elect86

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 .

SerVB avatar Sep 26 '18 06:09 SerVB

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

elect86 avatar Sep 26 '18 07:09 elect86