fork download
  1. {$APPTYPE CONSOLE}
  2. {$modeswitch nestedprocvars}
  3. uses SysUtils;
  4.  
  5. type
  6. users_t = (tarasB, superhackkiller1997, other_shit);
  7. say_ptr_t = procedure(str: PChar) is nested;
  8. const
  9. users: array[users_t] of PChar = ('tarasB', 'superhackkiller1997', 'other_shit');
  10.  
  11. function bind(usr: users_t): say_ptr_t;
  12. const
  13. local_usr: users_t = other_shit;
  14. procedure say(str: PChar);
  15. begin
  16. Writeln(ErrOutput, Format('%s: %s', [users[local_usr], str]))
  17. end;
  18. begin
  19. local_usr := usr;
  20. bind := @say
  21. end;
  22.  
  23. begin
  24. bind(tarasB)('shit');
  25. bind(superhackkiller1997)('i''m god');
  26. bind(other_shit)('ko-ko-ko')
  27. end.
Success #stdin #stdout #stderr 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
tarasB: shit
superhackkiller1997: i'm god
other_shit: ko-ko-ko