Mattias G?rtner wrote 13 lines
Zitat von Jan Kowalski :
> I need to call ProcThreadPool.DoParallel with "local" procedure as a
> parameter.
> Does DoParallel allow local procedures to pass a procedural parameters ?
> I get err: Error:
> Incompatible type for arg no. 1: Got "<address of local
> procedure(Int64,Pointer,TMultiThreadProcItem);Register>", expected
> "<procedure variable type of
> procedure(Int64,Pointer,TMultiThreadProcItem);Register>"
That would be really helpful.
But I don't know how to define a local procedure type:
I wouldn't be sure it's possible. It makes no sense.
My guess:
A local (nested) procedure has access to the outer(parent or grand-parent if recursive) procedures variables (stackframe). Therefore a local procedure must expect to be somewhere below this parent.
If it was given as a pointer to some other procedure/object, and then called later, this may happen outside the parent. Then no such stackframe does exist, and the local procedure can not work.
Martin
Show quoted text 28 lines
type
TMTLocalProcedure = procedure(Index: PtrInt; Data: Pointer;
Item: Pointer); ?
var
p: TMTLocalProcedure;
procedure TestWithLocalProc;
procedure LocalProc(Index: PtrInt; Data: Pointer; Item:
TMultiThreadProcItem);
begin
end;
begin
;
end;
Mattias
--
_______________________________________________
Lazarus mailing list
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus