tb0154.pp 525 B

1234567891011121314151617181920212223242526272829
  1. { %fail }
  2. {$mode objfpc}
  3. type
  4. tc = class
  5. left,right: tc;
  6. function test(var c: tc): boolean;
  7. end;
  8. testfunc = function(var c: tc):boolean;
  9. function foreach(var c: tc; p: testfunc): boolean;
  10. begin
  11. if not assigned(c) then
  12. exit;
  13. end;
  14. function tc.test(var c: tc): boolean;
  15. begin
  16. { The @tc.test is still a pointer to a method and not valid
  17. with a normal procvar }
  18. result := foreach(c.left,@tc.test);
  19. result := foreach(c.right,@tc.test) or result;
  20. end;
  21. begin
  22. end.