why `inline` classes allow only one constructor pa...
# announcements
d
why
inline
classes allow only one constructor param? it would be nice to have
inline class Pair
to avoid extra allocations
a
And how do you return a pair from a method?
d
And how do you maintain proper semantics for
volatile
fields with type of such an inline class?
d
And how do you return a pair from a method?
as usual:
return Pair(a, b)
And how do you maintain proper semantics for
volatile
fields with type of such an inline class?
can't help here. i'm not a kotlin compiler expert
d
Both of those are not possible with JVM bytecode.
On the JVM you can only return one thing from a function. You would have boxing at every method return of your inline class.
d
make sense
d
Same thing for volatile, not really possible on the JVM
This is one of the reasons project valhalla (native value types on the jvm) is taking a long time
d
now it's clear for me. thanks