Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

Delphi and the joy of Compiler Intrinsics – I cant use “Length” as a TFunc…

$
0
0

One of the reasons I favour using RTL based functionality over Delphi Intrinsic Routines like Length, Abs and others is that you cannot use compiler intrinsics in Generics. For instance Length is not compatible with TFunc<string, Integer> unless you declare it yourself like function StringLength(value: string): Integer; as otherwise you get en E2029 error (in this case the cryptic '(' expected but ';' found).

It’s one of the many areas where the Delphi compiler developers took a shortcut, but in this case I think the results are somewhat good.

Other reasons for using the RTL over compiler intrinsics have to do with scoping: the intrinsics are in the global scope which can clutter what you’re trying to work on.

So I much rather use the file and stream related functions when I’m actually working with a file or stream. For instance Assign for me has nothing to do with a file outside of a file context (it’s the reason AssignFile exists in the first place).

–jeroen

via: I cant use “Length” as a TFunc (tested in XE and XE6), but if…


Filed under: Delphi, Delphi 10 Seattle, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development

Viewing all articles
Browse latest Browse all 1440

Trending Articles