digitalmars.D.learn - A different vector op
- bearophile <bearophileHUGS lycos.com> Jul 01 2011
- Don <nospam nospam.com> Jul 05 2011
- bearophile <bearophileHUGS lycos.com> Jul 06 2011
- Wilfried Kirschenmann <wilfried.kirschenmann gmail.com> Jul 17 2011
- bearophile <bearophileHUGS lycos.com> Jul 18 2011
- Andrej Mitrovic <andrej.mitrovich gmail.com> Jul 18 2011
Currently this is not allowed, but do you desire a feature like this?
struct Foo {
int x, y;
int[100] array;
}
void main() {
auto foos = new Foo[100];
foos[].y += 10; // ***
}
Bye,
bearophile
Jul 01 2011
bearophile wrote:Currently this is not allowed, but do you desire a feature like this? struct Foo { int x, y; int[100] array; } void main() { auto foos = new Foo[100]; foos[].y += 10; // *** } Bye, bearophile
An interesting use case: void main() { cdouble[100] foos; foos[].re = 5.0; }
Jul 05 2011
Don:An interesting use case: void main() { cdouble[100] foos; foos[].re = 5.0; }
I don't often have to update arrays of complex numbers, more often I have to set or update a single field of an array of structs. Bye, bearophile
Jul 06 2011
On Sat, Jul 2, 2011 at 04:12, bearophile <bearophileHUGS lycos.com> wrote:Currently this is not allowed, but do you desire a feature like this? struct Foo { =C2=A0 =C2=A0int x, y; =C2=A0 =C2=A0int[100] array; } void main() { =C2=A0 =C2=A0auto foos =3D new Foo[100]; =C2=A0 =C2=A0foos[].y +=3D 10; // *** }
In fact, I would be more interested in the opposite : void main() { auto foos =3D new Foo[100]; auto ints =3D new int[100] ints =3D foos[].y; } This would simplify the wrinting of numerous application, especially in the writing of image/video processing (eg. rgb2yuv conversions) This would also simplify the writing of template library transforming "array of struct" to "struct of arrays" in a transparent manner for the library user. Wilfried
Jul 17 2011
Wilfried Kirschenmann:In fact, I would be more interested in the opposite :
If you allow that syntax on the left you probably allow it on the right too. Bye, bearophile
Jul 18 2011
float[] buffers = malloc..; float*[] CBuffers = buffers[].ptr; Pure win.
Jul 18 2011









bearophile <bearophileHUGS lycos.com> 