Skip to content

Evaluate MFVC for KorGE 4.0 #1257

Closed
Closed
@soywiz

Description

@soywiz

Multi Field Value Classes: Kotlin/KEEP#339

This will break compatibility (since we have mutable stuff, interfaces etc.), so it can only be considered for a major release.
Since 4.0 is still an alpha, we are still on time.

It has risks, but really really huge benefits and worth even using it as experimental.
To not depend on Kotlin timeline we could fallback to data class, accepting the performance penalty hit initially and manually crafting vector code in the time being inside the engine itself, and asuming it will "eventually" work faster and allocation-free.

The most evident example of this is:

interface IPoint { val x: Double; val y: Double }
data class Point(override var x: Double, override var y: Double) : IPoint

that will be converted into:

value class Point(val x: Double, val y: Double)

The IPoint interface will disappear, and Point will be immutable. The internal implementation will simplify a lot, and people will be able to do things like Point(1, 2) + Point(3, 4) fast and without allocations, so vector code won't require temporal points, and won't require hacks to look nice.

We can later change internal algorithms that are now inlined to use this, simplifying the implementation code a lot without affecting the exposed API.

Since 4.0 will exploit kproject for the first time a lot, doing this right now would reduce migrations to all the kprojects later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions