home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6623 < prev    next >
Encoding:
Text File  |  1992-11-16  |  1.5 KB  |  45 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!news.ccs.queensu.ca!slip203.telnet1.QueensU.CA!dmurdoch
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Re: Turbo and Procs/Fns as params..
  5. Message-ID: <dmurdoch.163.721919129@mast.queensu.ca>
  6. Lines: 33
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <1992Nov4.190755.25383@polaris.utu.fi> <mByRTB4w165w@digsol.jpunix.com> <1992Nov11.104939.14727@jyu.fi> <1992Nov11.111534.1@uwovax.uwo.ca> <1e6qnoINNnr6@matt.ksu.ksu.edu>
  10. Date: Mon, 16 Nov 1992 13:05:29 GMT
  11.  
  12. In article <1e6qnoINNnr6@matt.ksu.ksu.edu> holland@matt.ksu.ksu.edu (Rich Holland) writes:
  13. >>Turbo Pascal *DOES* Allow you to pass Procedures and Functions as parameters. 
  14. >>Unless I misinterpreted your comment....
  15. >
  16. >...but only if you pass them as a *pointer*
  17.  
  18. It's true that you don't pass the actual code around, but you don't need to 
  19. explicitly use pointers.  For example:
  20.  
  21. {$F+}  { this is necessary, since procedures to be assigned must be far }
  22.          
  23.   function add(a,b:integer):integer;
  24.   begin add := a+b end;
  25.  
  26.   function subtract(a,b:integer):integer;
  27.   begin subtract := a-b end;
  28.  
  29.   type
  30.     binaryop = function(a,b:integer):integer;
  31.  
  32.   var
  33.     someop : binaryop;
  34.  
  35.   begin
  36.     someop := add;
  37.     writeln('Some op of 5 and 3 is ',someop(5,3));
  38.   end.
  39.  
  40. The implementation makes someop a pointer to the entry point of the add 
  41. function here, but the syntax hides that.
  42.  
  43. Duncan Murdoch
  44. dmurdoch@mast.queensu.ca
  45.