Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEEP for multi-field value classes #339

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

zhelenskiy
Copy link
Contributor

No description provided.

@zhelenskiy zhelenskiy changed the title Create multi-field-value-classes.md KEEP for multi-field value classes Dec 21, 2022
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved

### Further development: `VArray`s and reification

One of other important steps of Value classes feature are Value arrays (`VArray`s) and reified classes and reified not-inline functions. They significantly extend applicability and optimizations of Value classes, **but they require MFVC to be already implemented** for that. Their importance is caused by frequent usage of containers that store and use stored values: they are currently handle value classes as boxed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
One of other important steps of Value classes feature are Value arrays (`VArray`s) and reified classes and reified not-inline functions. They significantly extend applicability and optimizations of Value classes, **but they require MFVC to be already implemented** for that. Their importance is caused by frequent usage of containers that store and use stored values: they are currently handle value classes as boxed.
One of other important steps of Value classes feature are Value arrays (`VArray`s) and reified classes and reified not-inline functions. They significantly extend applicability and optimizations of Value classes, **but they require MFVC to be already implemented** for that. Their importance is caused by frequent usage of containers that store and use stored values: they currently handle value classes as boxed.

An example of reified class will be helpful to understand why they require MFVC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that impact(mfvc + varrays) > impact(mfvc) + impact(varrays) because it also includes VArray<MFVC>s. I don't know how to formulate it properly.

proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
proposals/multi-field-value-classes.md Outdated Show resolved Hide resolved
@soywiz
Copy link

soywiz commented Feb 1, 2023

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)

Co-authored-by: Sergei Bulgakov <servbul@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants