Something I find quite annoying to do is to create a constructor that only sets the given properties. For example:
class Foo {
int x;
int y;
int z;
this(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
}
For structs, it automatically generates a constructor, and it'd be nice if you could autogenerate constructors for classes too, kinda like this:
class Foo {
int x;
int y;
int z;
default this(int x, int y, int z);
}
which would just be syntactic sugar for the former.
this could also be used for structs too if you've already specified a constructor:
struct Vector3 {
float x;
float y;
float z;
this(Vector2 v) {
x = v.x;
y = v.y;
}
default this(float x, float y, float z);
}
I feel like this would avoid a lot of boilerplate and make things more concise.