[fpc-pascal] Feature announcement: Dynamic array extensions
Ryan Joseph
ryan at thealchemistguild.com
Sat Jun 2 04:05:05 CEST 2018
> On Jun 2, 2018, at 5:19 AM, Nitorami <mneubauer at alice-dsl.net> wrote:
>
> Are you serious ? I have been using dynamic arrays a lot for processing of
> vectors and matrices containing floating point values, and implemented the +
> operator to do the obvious, add the elements of two vectors, NOT to concat
> them. This is just natural for floating point vectors, similar as with other
> basic mathemetical operators as *,-, /.
> Even if the "+" has always been used to concat strings, I find it a really
> really bad idea to extend that to danymic arrays.
Why are you using dynamic arrays for vectors/matricies? If what you have is an actual array you wish to grow then + would likely be an append operation.
var
v: TVec2;
begn
v := V2(1,1);
v += 10; // add 10 to x/y and get: v = 11,11
var
v: array of float;
begn
SetLength(v, 1);
v[0] := 1;
v += 10; // append 10 and get : v = 1,10
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list