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

Provide Mutable and Immutable Utypes #16

Open
SerVB opened this issue Jul 10, 2018 · 6 comments
Open

Provide Mutable and Immutable Utypes #16

SerVB opened this issue Jul 10, 2018 · 6 comments

Comments

@SerVB
Copy link
Contributor

SerVB commented Jul 10, 2018

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
Copy link
Collaborator

elect86 commented Jul 10, 2018

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
Copy link
Contributor Author

SerVB commented Jul 14, 2018

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
Copy link
Contributor Author

SerVB commented Sep 25, 2018

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
Copy link
Collaborator

elect86 commented Sep 26, 2018

Yep, thank you for assisting so far 👍

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

@SerVB
Copy link
Contributor Author

SerVB commented Sep 26, 2018

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
Copy link
Collaborator

elect86 commented Sep 26, 2018

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

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