On Tue, 25 Oct 2011, Marco van de Voort wrote:
In our previous episode, t...@free.fr said:
it will be more readable (imo)? The example still does not take
This seldom happens, but here I fully agree with Florian. ;-) Every
example of anonymous methods I have seen so far, can easily be done with
OP's procedure variables too. Maybe anonymous methods were introduced
in other languages because they didn't have something like OP's
procedure variables. I guess Object Pascal was yet again ahead of
everybody else. :)
I hinted on it in earlier procedures, but here a typical anonymous method
usecase.
[snip]
-~-------------------------------
Equivalent solution with anon functions:
targethread.queue(
procedure(targetobject:ttargetobject;a:integer;b:someobject;c:string)
begin
targetobject.destinationprocedure(a,b,c);
end;
Note how common this looks compared to the original.
One point is that you could do the above with a local (and named)
procedure as well, and still have all the context.
At the very least you would not be raping pascal's readability by putting a
complete procedure declaration inside a code block.
I don't know about you, but I have serious trouble reading the above
monstrosity.
It looks like you forgot the closing ) for the queue call.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal