Theoretically a pointer is a memory adsress to something in your program; and a function/procedure is stored in memory too. (I think you see where this is going by now). So is there any way to do the following:L

Code:
object
   Task = object
      MainProc: Pointer;
   end;

var
   TT: Task;

procedure foo();
begin
   writeln('HI');
end;

begin
   TT.MainProc := @foo;
   foo();
end.
However I cannot even get this to compile. Theoretically it should work but I have my reservations. I heard you can do this in C or whatever - so I was wondering if it could be done in pascal - since it would make my life sooo much easier. Think about it:
1 engine manages tasks
each task has init, main and end procedures and etc
you would not have to worry about modes and etc - just register your 'task' and let it all run. or something like that.
any pointers folks? (excuse pun)