KEEP icon indicating copy to clipboard operation
KEEP copied to clipboard

KEEP for multi-field value classes

Open zhelenskiy opened this issue 2 years ago • 1 comments

zhelenskiy avatar Dec 21 '22 16:12 zhelenskiy

There is another use-case I would like to share:

Here: https://docs.korge.org/ktcc/

There I'm doing black magic tricks that are really dirty to avoid allocations, and the code looks ugly. Being able to have something like:

value class MyPointer(val buffer: Buffer, val offset: Int) {
  var x: Double get() = buffer.getDouble(0); set(value) { buffer.setDouble(0, value) }
  var y: Double get() = buffer.getDouble(8); set(value) { buffer.setDouble(8, value) }
}

That would help to have C-like pointers: an array or buffer + offset (+ maybe optionally size)

soywiz avatar Feb 01 '23 17:02 soywiz