Array operations were added to the Quartex Pascal syntax to better adapt with JavaScript. Since JavaScript has no concept of pointers or direct memory access, all attempts at dealing with lists, linked lists etc. in the traditional way would involve a massive speed penalty. So where you under Delphi or FreePascal would allocate a TList or TObjectList instance - Quartex Pascal achieves better performance and identical functionality using ordinary arrays. All arrays support a complete set of operations, regardless of data-type, for inserting, removing, sorting and otherwise manipulate the content.


So where under vanilla Object Pascal you would write:


Procedure TMyObject.AddItem(const Value: Integer);

var

 mLen: Integer;

Begin

 mLen := length( fMyArray );

 SetLength( fMyArray, mLen +1);

 fMyArray[ mLen ] := Value;

end;


Quartex Pascal has this functionality "built-in" for all arrays, as long as the data-types match. When you combine this with property expressions, the result is a powerful and alternative way of achieving the same with less resources and better performance.


fMyArray.add( Value );


As of this writing, the following operations can be performed on all array types:


  • Add
  • Clear
  • Copy
  • Count
  • Delete
  • High
  • Low
  • IndexOf
  • Insert
  • Length
  • Map
  • Peek
  • Pop
  • Push
  • Remove
  • Reverse
  • SetLength


Quartex Pascal has no need for classes like TObjectlist, TList, TStringlist or TStack, since all arrays have Push(), Pop(), Peek() methods.