Lambdas
Lambdas is an extremely handy feature that, like partial and anonymous classes, is not yet a part of Delphi or Freepascal. The DWScript syntax supports several kind of lambdas, which definitively makes some of the NodeJS asynchronous easier to deal with:
For instance, the following closure:
var repeater := TQTXEventRepeater.Create(
function (Sender: TObject): boolean
begin
Result := MyFunction;
end,
5000);
By using a lambda we can shorten the amount of text considerably:
var repeater :=
TQTXEventRepeater.Create(lambda => MyFunction, 5000);
Lambda statements (i.e. "procedure" kind of closures) can likewise be written as such:
ButtonOK.OnClick := lambda ShowMessage("You clicked the button!") end;