I am extremely uncomfortable with the use of + as a concatenation operator due to its being far more useful as an arithmetic operator when numeric arrays are being manipulated, and for the sake of discussion suggest >< instead.
Assuming
TVertexDegs= record
lat, lon: double
end;
TRegionDegs= array of TVertexDegs;
then I presume that concatenation of a single element is best done like
operator >< (const region: TRegionDegs; const point: TVertexDegs): TRegionDegs;
begin
result := region;
SetLength(result, Length(result) + 1);
result[High(result)] := point
end { >< } ;
I'm uncomfortable, however, with the situation where an element is being tacked onto the front. Is there something more efficient than
operator >< (const point: TVertexDegs; const region: TRegionDegs): TRegionDegs;
var
i: integer;
begin
SetLength(result, Length(region) + 1);
result[0] := point;
for i := 0 to High(region) do
result[i + 1] := region[i]
end { >< } ;
What about the third case, where both parameters are arrays?
And can these three cases be generalised using generics?
Background: APL uses , for concatenation, Perl uses . and for my own domain-specific compilers I favour _ Under the circumstances, I think that Object Pascal's >< is fair game.
MarkMLl