On Tue, 25 Oct 2011, Marco van de Voort wrote:

In our previous episode, michael.vancann...@wisa.be said:

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.

One can debate the syntax. I won't, since even while I have similar
reservations, that will lead to the usual Delphi sucks debate, possible
implementation of an-orphaned-at-birth FPC specific syntax, and in the end
the Delphi syntax always prevails, leading to a lot of wasted time in
discussion and implementation of own inventions.

That is such a common pattern on these lists, I'm thinking about an acronym
for it to save time :-) So sufficient to say, I think own syntax inventions
are worse than the problem in the first place, and sooner or later we have
to live with it.

However there was also a questioning of the use(functionality) of anonymous
functions, I hope that I have now at least explained a typical use case, so
we can put that to rest.

Please note that I didn't question their use, just the syntax :)

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to