struct initialization as positional parameters?
When writing a struct literal, the syntax requires each attribute and value to be specified. It would be neat to be able to simply pass in values positionally, and automatically assigning to the correct attribute by using the order of attributes in the struct definition
i.e.:
struct Vector {
x, y
}
onflag {
forever {
Vector my_pos = Vector{x: x_position(), y: y_position()};
}
}
becomes:
struct Vector {
x, y # Here, attribute order is defined. Order of these attributes will become important
}
onflag {
forever {
Vector my_pos = Vector{x_position(), y_position()}; # Known to be x and y, since that is the order it is defined above
}
}
potentially, even this:
struct Vector {
x, y
}
onflag {
forever {
Vector my_pos = Vector{x_position(), y: y_position()}; # Passing x positionally, and y via key-value defintion
}
}
This would be a bit similar to python
This would make repetitive struct literals less painful to type, especially lines (x1, y1, x2, y2)
However this would conflict with #71
Potentially a character like * may be needed to change behavior like how *args works in python
currently the only solution for this is to use a macro
since the struct syntax is based on rust syntax, maybe this isn't a good idea. Just use a macro instead
the issue is that this makes the order of fields a breaking change, and there is nothing in scratch where the order matters