On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property with the
current
compiler. Can anyone explain why and when I should use the
@property tag?
Consider the following struct:
struct Vector4 {
@property float x() { return vec[0]; }
.....
.....
@property void x(float _x) { vec[0] = _x }
.....
.....
private:
float[4] vec;
}
Here I like to use static array for storing components of vector
because I want to use special operations on arrays while taking
advantage of auto-vectorization if possible. In this case, it is
very convenient to use properties.