[fpc-pascal] Delphi compatible anonymous functions

Dmitry Boyarintsev skalogryz.lists at gmail.com
Mon May 26 17:17:10 CEST 2014


On Fri, May 16, 2014 at 11:45 AM, Craig Peterson
<craig at scootersoftware.com>wrote:

> 1) I want to use the OmniThreadLibrary.  Setting up objects and thread
> descendents is fine in moderation, but it's too much of a hassle when
> you just want a quick parallel for loop.
>

Anonymous functions are bad for unit testing.
Why? Because they do exist only at the place of the call and depends on the
state of at the time the call.
And thus they cannot be tested separately without the caller.

I'd assume the parallel execution is definitely needed since the actions
you're separating are time consuming.
They're time consuming, because they might be complex.
Having an ability to test a complex code separately (outside the execution
environment/application) is a big benefit.

Yet again - the re-usage of the code.
What if you switch from OmniThreadLibrary to OpenMP (or whatever other
threading library) that doesn't provide support for anonymous functions.
What if you'd need to write a separate application, that doesn't have the
requirement to use threads.
Using the regular code (in procedures or methods) reduces the number of
changes you'd need to do.

I've mentioned it before OmniThreadLibrary doesn't require you to use
anonymous functions.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140526/cafd1605/attachment.html>


More information about the fpc-pascal mailing list