[fpc-pascal] Free Pascal 2.4.0 released

Anthony Walter sysrpl at gmail.com
Sat Jan 2 16:13:40 CET 2010

On Sat, Jan 2, 2010 at 5:44 AM, Paul Ishenin <webpirat at mail.ru> wrote:
> Jonas Maebe wrote:
>> http://edn.embarcadero.com/article/33336
>> Note that even Delphi doesn't have them yet ("it might also turn up in
>> Delphi in the future").
> Looks as something related to:
> http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then this is
> already implemented in delphi.

Something I've really found useful in C#/.NET is lamda functions and
capturing locals (closures). This feature really solves asynchronous
design for me at least. If you can follow this code (note below how
url and dimension locals are captured):

// inside a static class called Async ...
public delegate object Task();
public delegate void Complete(object result);
public static void Execute(Task task, Complete complete) { ... }

Which can then lead to code like this:

downloading = true;
progressControl.Status = ProgressStatus.Busy;
Async.Execute(() => Download.BitmapScaled(url, maxWidth, maxHeight),

... and in DownloadComplete:

private void DownloadComplete(object result)
  downloading = false;
  progressControl.Status = ProgressStatus.None;
  if (result is Exception)
    progressControl.Text = "An error occurred during download";
    progressControl.Text = String.Empty;
    imageControl.Image = result as Bitmap;

More information about the fpc-pascal mailing list