Sam Stone
09/27/2023, 2:48 PMPair
and Triple
called Tuple
that uses code gen to create variables first
, second
, etc. (or ItemN
like in C#), based on the number of arguments passed in.
Is this possible? Where would I begin? I have never made a compiler plugin.ephemient
09/27/2023, 6:29 PMephemient
09/27/2023, 6:29 PMTuple4
, Tuple5
, etc.) for them to be passed aroundephemient
09/27/2023, 6:31 PMfun <T1, T2, T3, T4> Tuple(first: t1, second: t2, third: t3, fourth: t4): Tuple4
fun <T1, T2, T3, T4, T5> Tuple(first: t1, second: t2, third: t3, fourth: t4, fifth: t5): Tuple5
...
if you want them all to have a "constructor" named Tuple
ephemient
09/28/2023, 12:24 AMTuple<T1, T2, T3, T4>
etc. that are all backed by some internal class TupleN(data: Array<Any>)
. dunno about it being worthwhile though, since unnamed tuples aren't an encouraged pattern in KotlinSam Stone
10/06/2023, 2:46 AMaru
10/10/2023, 11:25 AMdata class
feature with componentN()
functions? https://kotlinlang.org/docs/data-classes.htmlSam Stone
10/16/2023, 2:57 AMN
only goes up to the 40's as of recent
2. The only way to do it that way is to have many nullable properties, so no type safety.