Allow swizzle field names in array initialization #4289
Closed
Porem5002
started this conversation in
Ideas/Requests
Replies: 1 comment
-
I'm pretty sure we have an array initializer that allows specific indices for values: a := [?]string {
0 = "pawn",
3 = "knight",
10 = "rook",
} In which case it would make sense if this syntax was allowed for vector initialization. However one thing that I'm curious is whether that'll conflict with enum-array initialization, in particular where: E :: enum { x, y, z, w }
a := [E]int {
x = 1,
y = 2,
z = 3,
w = 4,
} Not making any point, just bringing up ideas that may hinder the viability of implementation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue: #4288
This feature comes from something that was previously possible using the raylib bindings.
Until around dev-2023-11, the Color type from raylib was defined as a struct so we could write code like this and it was pretty obvious what it would do:
But since then (after this more precisely) this type is defined as a fixed array, which allows for more flexibility but also means that the previous code no longer compiles since those fields don't actually exist in an array.
My request is to allow for this kind of syntax for initializing arrays, making the language more consistent.
Beta Was this translation helpful? Give feedback.
All reactions