What is the reasoning behind <https://kotlinlang.o...
# kotlin-native
a
What is the reasoning behind https://kotlinlang.org/api/core/kotlin-stdlib/kotlinx.cinterop/get.html returning the numeric types directly vs everything else wrapped in its
CVariable
wrapper? see 🧵
i.e. if I have two arrays like
Copy code
val bools = allocArrayBooleanVar(count)
val ints = allocArrayIntVar(count)
where I want to pass a single element each to a function
Copy code
fun foo(bar: BooleanVar, baz: IntVar)
I can just use the default version of
operator fun reified T : CVariable CPointerT.get(index: Int): T
for
bar
(returning
BooleanVar
), while with
foo
I end up with
operator fun T : Int CPointer<IntVarOfT>.get(index: Int): T
(returning
Int
). So instead of having a call like
Copy code
foo(bools[index], ints[index])
I end up with something like
Copy code
foo(bools[index], (ints + index)!!.pointed)
To me this feels very inconsistent?
y
FWIW you can do
ints.get<IntVar>(index)