Delphi Handbooks Collection


Delphi XE Handbook


Delphi 2010 Handbook


October 11, 2012

Small Hidden New Features in Delphi XE3 RTL

I've done some research for a Delphi XE3 workshop I'm holding at my office tomorrow (in Italian). Beside the relevant new feature, I found some minor but interesting ones.

I've done some research for a Delphi XE3 workshop I'm holding at my office tomorrow (in Italian). Beside the relevant new feature, I found some minor but interesting ones. Here I'm focusing mostly in the RTL area.

System Unit

Ignoring some relevant changes (mostly in preparation for the new mobile compiler), here are some nice tidbits:

  • The classic TMethod record (used for method references, aka events) has comparison operators
  • The Pos function has an offset, basically duplicating PosEx.
  • What is the TPtrWrapper record? An “opaque pointer wrapper”... and this means? (I know, I'm teasing)
  • Plus the helpers for Single, Double, Extended.

 

System.Classes

In many cases, there is not extended usage of generic lists for implementations (rather than pointer-based TList). Examples are the FComponents list inside a TComponent. Also, arrays are often replaced with TList<T>.

There are many changes to streams. Beside the new Skip method, there are many type-safe ReadData and WriteData methods, replacing the untyped Read and Write and clearly meant for the "nextgen" compiler, as the source code clearly hints.

There are also new custom attributes for what were formerly compiler-specific RTTI extensions for properties: Default, NoDefault, and Stored (plus a new ObservableMember). This new mechanism for defining the default values for properties will have a significant impact going forward and is already used in the database part of the RTL. This clearly deserves a more in-depth analysis.

 

New RTL Units

Finally, here are some of the new RTL units:

  • System.Actions with shared code between VCL and FMX
  • System.Sensors which has core platform-agnostic support for sensors of the following categories (comign from the internal sensor-types enumeration): Location, Environmental, Motion, Orientation, Mechanical, Electrical, Biometric, Light, and Scanner
  • System.Sqlite with the low-level interfaces to the Sqlite database (there is also higher level support in the form of a dbExpress driver).

Conclusion

As always, beside major features each new version of Delphi has some small improvements here and there, which can help your daily work. Of course, developers would want more...

 





 

5 Comments

Another feature in the future compiler: ARC memory model 

 Delphi XE3 is also preparing (weak) reference counting for class 
instances - future sounds like Apple's ARC memory model.
See http://blog.synopse.info/post/2012/10/06/Delphi-XE3-is-
preparing-reference-counting-for-class-instances
Comment by A. Bouchez [http://synopse.info] on October 11, 18:21

Small Hidden New Features in Delphi XE3 RTL 

See TMarshaller in sources:

for example RenameFile in XE3:

function RenameFile(const OldName, NewName: string):
Boolean;
{$IFDEF MSWINDOWS}
begin
  Result := MoveFile(PChar(OldName), PChar(NewName));
end;
{$ENDIF MSWINDOWS}
{$IFDEF POSIX}
var
  M1, M2: TMarshaller;
begin
  Result := __rename(M1.AsAnsi(OldName,
CP_UTF8).ToPointer, M2.AsAnsi(NewName,
CP_UTF8).ToPointer) = 0;
end;
{$ENDIF POSIX}


Comment by Radek Cervinka [http://delphi.cz] on October 11, 19:21

Small Hidden New Features in Delphi XE3 RTL 

 Hi Marco!
What about new helpers to string, double and extended?
cheers,
P
Comment by Pawel [http://blogs.embarcadero.com/pawelglowacki] on October 11, 20:14

Small Hidden New Features in Delphi XE3 RTL 

And then there is the biggest overlooked change; All
of the refactoring to remove (most of?) the "with"
statements from the RTL.

I bet Nick Hodges is doing the dance of joy!
Comment by Bruce McGee on October 12, 00:25

Small Hidden New Features in Delphi XE3 RTL 

 Pawel,
be careful with string helpers. TStringHelper has few
methods, wich are not implemented (result := false and
so on. see CompareOrdinal, GetHashCode,
IsNullOrWhiteSpace). 
also it is important to know that TStringHelpers is
compiled with {$ZEROBASEDSTRINGS ON}, it means that code:
'asd'.indexOf('a',1) returns -1, while we expect 1.
and 'asd'.IndexOf('a',0) returns 0;

the same thing with Chars[]: str.Chars[0] equals
str[1] and so on.
Comment by ter [http://teran.karelia.pro] on October 12, 07:13


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.