I tried this out today on FPC fixes_3_0 and was surprised to see it worked:
type StringHelper = record helper for string private function GetLength: Integer; procedure SetLength(Value: Integer); function GetIsEmpty: Boolean; function GetIsWhitespace: Boolean; public 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; end; 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.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal