home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- 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
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Subject: Re: Turbo and Procs/Fns as params..
- Message-ID: <dmurdoch.163.721919129@mast.queensu.ca>
- Lines: 33
- Sender: news@knot.ccs.queensu.ca (Netnews control)
- Organization: Queen's University
- 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>
- Date: Mon, 16 Nov 1992 13:05:29 GMT
-
- In article <1e6qnoINNnr6@matt.ksu.ksu.edu> holland@matt.ksu.ksu.edu (Rich Holland) writes:
- >>Turbo Pascal *DOES* Allow you to pass Procedures and Functions as parameters.
- >>Unless I misinterpreted your comment....
- >
- >...but only if you pass them as a *pointer*
-
- It's true that you don't pass the actual code around, but you don't need to
- explicitly use pointers. For example:
-
- {$F+} { this is necessary, since procedures to be assigned must be far }
-
- function add(a,b:integer):integer;
- begin add := a+b end;
-
- function subtract(a,b:integer):integer;
- begin subtract := a-b end;
-
- type
- binaryop = function(a,b:integer):integer;
-
- var
- someop : binaryop;
-
- begin
- someop := add;
- writeln('Some op of 5 and 3 is ',someop(5,3));
- end.
-
- The implementation makes someop a pointer to the entry point of the add
- function here, but the syntax hides that.
-
- Duncan Murdoch
- dmurdoch@mast.queensu.ca
-