<p>Am 24.02.2015 11:24 schrieb "Michael Schnell" <<a href="mailto:mschnell@lumino.de">mschnell@lumino.de</a>>:<br>
><br>
> On 02/24/2015 11:12 AM, Sven Barth wrote:<br>
>><br>
>><br>
>><br>
>> AFAIK Delphi doesn't use the term "closures" though conceptually anonymous functions (as implemented by Delphi) are one way to achieve them.<br>
>><br>
> What is the advantage of using a "closure" and/or an "anonymous function" instead of just doing "free;" as the last instruction of a normal procedure of some object ?<br>
></p>
<p>I'll comment in context to the example you gave for passing parameters to Queue/Synchronize (a custom class with a suitable public method)</p>
<p>Closures:<br>
- no need to declare a special class that handles the call<br>
- no need to allocate a class<br>
- no need to call "Free"</p>
<p>And with anonymous functions:<br>
- the functionality is defined where it is needed (inside the parameter clause of Queue/Synchronize or in case of nested procedures at least inside the same method)</p>
<p>Regards,<br>
Sven</p>