Hello. I'm just getting started, so have many noob...
# kotlin-native
g
Hello. I'm just getting started, so have many noob questions. How can I pass a variable to a function by reference and get the changed value?
g
There is no pointers, so you cannot pass primitive value by reference. But you can pass an object with mutable value to a function and this function can change it. So the same evaluation strategy as Java (and actually many other languages)
o
Yes, whenever you pass object to function, it is passed by reference. No difference with Kotlin/JVM or JS
g
I want to pass int by reference to a C function via interop. What I did now is this:
Copy code
memScoped {
   val a = alloc<IntVar>()
   call(a.ptr)
   println(a.value)
}
is there any way to use kotlin Int instead of IntVar?
any best practive?
any way to avoid explicit allocation?
o
We plan to support local references, but currently it’s the only option
g
thank you!