Scalar + array operations

2014-05-21 Thread Stefan Frijters via Digitalmars-d-learn
When working on my current project (writing a numerical simulation code) I ran into the following issue when trying to multiply a vector (represented by a fixed-length array) by a scalar: import std.stdio; void main() { int ifoo = 2; int[3] ibar = 1; double dfoo = 2.0; double[3]

Re: Scalar + array operations

2014-05-21 Thread bearophile via Digitalmars-d-learn
Stefan Frijters: Is this by design? It was very surprising to me, especially since all other combinations do seem to work. I don't know if this situation is by design. At first sights it seems a limitation that could be removed. Bye, bearophile

Re: Scalar + array operations

2014-05-21 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 11:45:57 UTC, Stefan Frijters wrote: When working on my current project (writing a numerical simulation code) I ran into the following issue when trying to multiply a vector (represented by a fixed-length array) by a scalar: import std.stdio; void main() { int

Re: Scalar + array operations

2014-05-21 Thread Stefan Frijters via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 13:52:47 UTC, John Colvin wrote: Please file a bug, there's no reason for that not to work, it just needs to be implemented properly. Ok, thanks for confirming. Filed as https://issues.dlang.org/show_bug.cgi?id=12780 .

Re: Scalar + array operations

2014-05-21 Thread Francesco Cattoglio via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 13:52:47 UTC, John Colvin wrote: On Wednesday, 21 May 2014 at 11:45:57 UTC, Stefan Frijters wrote: I would have expected the last case to work as well, but I get testarr.d(20): Error: incompatible types for ((dfoo) * (ibar[])): 'double' and 'int[]' Is this by

Re: Scalar + array operations

2014-05-21 Thread Stefan Frijters via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 17:07:27 UTC, Francesco Cattoglio wrote: On Wednesday, 21 May 2014 at 13:52:47 UTC, John Colvin wrote: On Wednesday, 21 May 2014 at 11:45:57 UTC, Stefan Frijters wrote: I would have expected the last case to work as well, but I get testarr.d(20): Error: