Language Features Specific to Delphi Support

This topic covers festures in Oxygene (and other Elements languages) that have been added or perform differently, specifically to support Delphi SDKs and APIs.

Managing life-time with using blocks

The using Statement in Oxygene and other languages that support equivalents work with Delphi object model classes to automatically free them when the using block and its variable goes out of scope.

using lList := new TStringList do begin
  lList.Add('Hello');
end;    
using lList = new TStringList() 
{
  lList.Add("Hello");
}
__using lList = TStringList() {
  lList.Add("Hello")
}
try (var lList = new TStringList()) {
  lList.Add("Hello");
}
Using lList = new TStringList() 
  lList.Add("Hello");
End Using

This is the equivalent of an explicit try/finally block around the code, with a call to lList:Free in the finally section. And of course the added benefit that lList will be out of scope and unreachable after the block.