Add struct as a main language feature #2101
Labels
feature
Proposed language feature that solves one or more problems
state-duplicate
This issue or pull request already exists
Dart should add
struct
s the same way C# did. Structs are in-place, meaning that the place for the members is pre-reserved, like for native types.Here an example on how the memory structure may look like:
Class
Structs are passed by value, meaning they are being copied on each assignment. This can (or cannot) improve performance in certain situations. Also, the GC does not track structs on its own.
Structs should be used on small datatypes like: (fixed) Vectors ->
Vector2
or similar.This can heavily improve performance in games, as no additional allocations are needed and as no GC tracking is required.
This feature should be high priority, as Flutter apps and game engines rely on it (like Flame).
The text was updated successfully, but these errors were encountered: