On Tue, 19 Jun 2012 00:22:29 +0300 ik <ido...@gmail.com> wrote: > Hi, > > I'm playing a bit with the notion of execute a method dynamically on demand. > I'ved created the following PoC: > https://gist.github.com/2950789 > > It works, but for some strange reason, I find myself feeling that I'm > missing something, or it should be done differently. > Does this code written properly, or should I do it differently ?
function ExecMethod(Instance : TObject; Name : String) : Boolean; var Exec : TMethod; begin Exec.Code := TProcedure(Instance.MethodAddress(Name)); Exec.Data := Instance; Result := Assigned(Exec.Code); if Result then TProcedureOfObject(Exec)(); end; Mattias _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal