KEEP icon indicating copy to clipboard operation
KEEP copied to clipboard

KEEP for Self types

Open maxim092001 opened this issue 1 year ago • 4 comments

PR

maxim092001 avatar May 08 '23 18:05 maxim092001

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

mgroth0 avatar May 29 '23 12:05 mgroth0

mgroth0

Hi!

There is KT-6494 and PR

maxim092001 avatar May 29 '23 13:05 maxim092001

Cool to have this, reduce a lots of boilerplates

He-Pin avatar Jun 02 '23 05:06 He-Pin

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.

Laxystem avatar Oct 21 '23 14:10 Laxystem