In our previous episode, Bernd said:
> > Equivalent solution with anon functions:
> >
> > targethread.queue(
> > ? procedure(targetobject:ttargetobject;a:integer;b:someobject;c:string)
> > ? ? ? ? ? ? ?begin
> > ? ? ? ? ? ? ? ?targetobject.destinationprocedure(a,b,c);
> > ? ? ? ? ? ? ?end;
> 
> shouldn't this be
> 
> targethread.queue(
>       procedure
>              begin
>                targetobject.destinationprocedure(a,b,c);
>              end;
> 
> without any parameters since all these variables are captured from the
> current scope into the closure? The other thread should not need to
> know anything about them to call it.

Afaik you are right. Delphi also allowed the other form, but I thought the
syntax would force immediately evaluation of the parameters (and thus only
the parameters be stored in case any of a ,b or c are expressions, not all
parts of the expressions).

But indeed then the other side also has to call it with parameters, and in
this example that defeats the purpose.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to