Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language    [ Add a report in this area ]  
Report #:  104907   Status: Open
Extent Arrays with methods the same was Record was.
Project:  Delphi Build #:  16.0.4429.46931
Version:    16.4 Submitted By:   David Tetard
Report Type:  New Feature Request Date Reported:  4/14/2012 11:25:19 PM
Severity:    Infrequently encountered problem Last Updated: 8/6/2012 12:54:58 PM
Platform:    All platforms Internal Tracking #:  
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 20
Description
IMHO, the biggest improvement to records in recent years was the addition of methods.
I suggest that possibility for developers to define methods for arrays could be added too to great adavantage, especially open arrays.

I can easily see the following be used in numerous units in my apps:

Type
      TMyArray : Array Of Integer
             Function Add : Integer;
             Procedure Clear;
      End;


Procedure TMyArray.Clear;
Begin
     SetLength(Self, 0);
End;

Function TMyArray.Add : Integer;
Begin
     ...
End;


Var
    MyArray : TMyArray;
    Index : Integer;
Begin
     MyArray.Clear;
     Index := MyArray.Add;
     MyArray[Index] := 1;
     ...
End;
Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments

Alexey Ponomarev at 4/19/2012 10:29:59 PM -
Agree,
Another great improvement would be to introduce helpers for all types including integers, arrays, interfaces, floats, whatever you want, and not only for classes and records.

E.g.
TIntToStringHelper = class helper for integer
public
  function ToString: string; inline;
end;

function TIntToStringHelper.ToString: string;
begin
  result := IntToStr(self);
end;

Server Response from: ETNACODE01