On 02/06/18 08:00, Ryan Joseph wrote:
On Jun 2, 2018, at 2:42 PM, Sven Barth via fpc-pascal <fpc-pascal@lists.freepascal.org>
wrote:> > It wasn't me who implemented that part. I personally had planned to do it with
a warning for existing overloads, but Florian beat me to it and implemented it this way.
Though when asked by me he did say that we'll wait and see if people complain... So *maybe*
we'll change this.>
btw why can’t there be both? You can have multiple + operators for any given
dynamic array type can’t you?
type TArrayOfInteger = array of integer;
operator + (left: TArrayOfInteger; right: integer): TArrayOfInteger;var i:
integer;begin for i := 0 to high(left) do left[i] += 1;end;
operator + (left: TArrayOfInteger; right: TArrayOfInteger):
TArrayOfInteger;begin result := Concat(left, right);end;
Agreed, both are extremely useful and have an intuitively unambiguous
meaning (unlike - which can be useful but doesn't have an unambiguous
meaning).
However as Dennis points out + is also essential for vector operations.
Perhaps either leaving it to the programmer to define what's needed
would be the best approach, or alternatively splitting dynamic arrays
into mathematical vectors and non-mathematical collections. Or relaxing
the requirement that only predefined operators can be redefined, so that
something like _ could be used for concatenation.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal