About the author
In Javascript, you can define an anonymous function that can be executed immediately. It is called an Immediate Invocation Function Expression, aka IIFE.
First, you declare the function, like so:
function () { console.log('Immediately invoked function execution'); }
Then, you wrap it up in ():
(function () { console.log('Immediately invoked function execution'); })
Finally, you add another () to execute it:
(function () { console.log('Immediately invoked function execution'); })()
In Delphi, similarly, you can define an anonymous method:
procedure begin WriteLn('Hello world'); end
Then, you wrap it up with ():
(procedure begin WriteLn('Hello world'); end)
And finally, execute it!
(procedure begin WriteLn('Hello world'); end)();
Here's another example:
WriteLn((function (const X: string): Boolean begin WriteLn(X); Result := True; end)('Hello'));
The output for this shows the following x:
HelloTRUE
Continued discussion of undocumented Delphi 8 Property Access Specifiers, and other ways of adding and removing delegates / events handlers, including clearing the list of all the delegates / event handlers.