[fpc-pascal] Record helpers on built in types?

Anthony Walter sysrpl at gmail.com
Tue Feb 17 23:28:02 CET 2015

I tried this out today on FPC fixes_3_0 and was surprised to see it worked:

  StringHelper = record helper for string
    function GetLength: Integer;
  procedure SetLength(Value: Integer);
    function GetIsEmpty: Boolean;
    function GetIsWhitespace: Boolean;
    function BeginsWith(const S: string): Boolean;
    function EndsWith(const S: string): Boolean;
    function Trim: string;
    property Length: Integer read GetLength write SetLength;
    property IsEmpty: Boolean read GetIsEmpty;
    property IsWhitespace: Boolean read GetIsWhitespace;

I love this and would like to know if this is going to be an officially
supported feature and can I depend on it to work going forward?

I wrote a string library which is maybe 10x faster for searching,
replacing, trimming strings than the default RTL functions and was
considering moving them and other add-ons to record helper properties and
methods as above.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150217/e9bb7deb/attachment.html>

More information about the fpc-pascal mailing list