Kotlin-native: Value Types (Struct, Passing by value)

Created on 3 Nov 2017  路  6Comments  路  Source: JetBrains/kotlin-native

Hi

Is it possible to have something like struct ? i need to be able to pass data by value, for example Vector2 for a position without having to duplicate it

Thanks!

Most helpful comment

This should be added now imo, or it'll be problematic when Valhalla is released, and even without Valhalla value type is important, and the application/system is a false problem, because i'm making an app i shouldn't care about performance ? this is stupid, i don't want my app to waste memory/cache miss because designer didn't want to add value type

All 6 comments

It really depends on what you're trying to achieve. Generally speaking, K/N shall manifest reasonable performance as an application language, but it is not a high performance language by design.

This is really important, for making game for example

Even Java is about to add value types, so kotlin jvm will have it

I think value types will make a problem in software design, how could I know that this type is a struct?

I think value types will make a problem in software design, how could I know that this type is a struct?

Ends up being a bit of a Kotlin language design question (would affect all platforms Kotlin targets - JVM, JS, and Native).

K/N shall manifest reasonable performance as an application language

That is assuming the software being developed isn't system level (OS's, hardware drivers, games? etc). Embedded software is one of those grey areas (some aspects are high level while other aspects are system level).

This should be added now imo, or it'll be problematic when Valhalla is released, and even without Valhalla value type is important, and the application/system is a false problem, because i'm making an app i shouldn't care about performance ? this is stupid, i don't want my app to waste memory/cache miss because designer didn't want to add value type

Having this discussion here doesn't make much sense.
Kotlin/Native has basic support for vector types: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native/-vector128/
If you have a specific feature request, feel free to submit it to YouTrack: https://kotl.in/issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

brettwillis picture brettwillis  路  4Comments

Marcopohlo picture Marcopohlo  路  4Comments

msink picture msink  路  4Comments

dpomada picture dpomada  路  3Comments