[fpc-devel] Question about Syntax: I there a reason for this design?

Samuel Herzog sam_herzog at yahoo.com
Sun Sep 21 08:10:55 CEST 2014


I was looking at the following example in DXE7
http://delphiaball.co.uk/
procedure TFormThreading.Button1Click(Sender: TObject); var aTask: ITask; begin // not a thread safe snippet aTask := TTask.Create (procedure () begin sleep (3000); // 3 seconds ShowMessage ('Hello'); end); aTask.Start; end;

I dislike this syntax and tried to write it this way because I think it's better readable code.
But it's not accepted.

procedure TFormThreading.Button1Click(Sender: TObject); var aTask: ITask; 
procedure MyTask; begin sleep (3000); // 3 secondsShowMessage ('Hello');end

begin // not a thread safe snippet aTask := TTask.Create(MyTask); aTask.Start; end;
I just wonder if there is a valuable reason to do it why my example is not allowed or would it be easy to make this available in free-pascal?

Thank you.
Sam





________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140920/62106126/attachment.html>


More information about the fpc-devel mailing list