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

KEEP for Self types #356

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

KEEP for Self types #356

wants to merge 17 commits into from

Conversation

maxim092001
Copy link

@maxim092001 maxim092001 commented May 8, 2023

PR

@mgroth0
Copy link

mgroth0 commented May 29, 2023

I really like this. Are there any corresponding YouTrack issues or other conversations that we can link to?

@maxim092001
Copy link
Author

mgroth0

Hi!

There is KT-6494 and PR

@He-Pin
Copy link

He-Pin commented Jun 2, 2023

Cool to have this, reduce a lots of boilerplates

proposals/self-types.md Outdated Show resolved Hide resolved
proposals/self-types.md Outdated Show resolved Hide resolved
@maxim092001 maxim092001 marked this pull request as ready for review June 9, 2023 21:56
@Laxystem
Copy link

Laxystem commented Oct 21, 2023

I would replace the annotation with a modifier. Gate-locking a language feature behind an annotation isn't a common Kotlin thing to do - annotations are usually used for metadata (e.g., @PublishedApi).

class A<this Self>

class B<this Self, T>

class C<T, this Self>

class D<out this Self>

That way, you reduce the confusion from the explicit-self-generic syntax (the C<Int, C<Int, *>> instead of C<Int> part), remove the need for an annotation (therefore increasing readability and beginner-approachability), and allows using whatever name (and order) you want for the generic instead of forcing it by language.

The modifier's name could also be self, current or dynamic.

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

Successfully merging this pull request may close these issues.

5 participants