home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4478 < prev    next >
Encoding:
Text File  |  1992-07-20  |  2.2 KB  |  59 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!news.belwue.de!eratu.rz.uni-konstanz.de!nyx.uni-konstanz.de!phfrom
  3. From: phfrom@nyx.uni-konstanz.de (Hartmut Frommert)
  4. Subject: Re: Functions and Procedures as Parameters
  5. Message-ID: <phfrom.185@nyx.uni-konstanz.de>
  6. Sender: usenet@eratu.rz.uni-konstanz.de
  7. Organization: Dept. of Physics, University of Constance
  8. References: <BrpxpG.351@ux1.cso.uiuc.edu>   <1992Jul21.050043.7238@usenet.ins.cwru.edu>
  9. Date: Tue, 21 Jul 1992 08:46:24 GMT
  10. Lines: 47
  11.  
  12. bx304@cleveland.Freenet.Edu (Jeff Epler) writes:
  13.  
  14. >In a previous article, husak@ux1.cso.uiuc.edu (Stephen R. Husak) says:
  15.  
  16. >>I've been trying to implement the following in TP5.5... [..]
  17.  
  18. I use TP 6.0, bu think this makes no diff here..
  19.  
  20. >>I want to pass a function into another function:
  21. >>
  22. >>eg -- function First(a,b: real;
  23. >>                     function test(x:integer):integer);
  24. >> [..]    
  25.  
  26. >[..]
  27. >I *think* that one must declare a TYPE that is a function.  What you
  28. >have above doesn't work for the same reason that function
  29. >george(harry:array[1..20] of char):char; doesn't work.
  30.  
  31. You're right.
  32.  
  33. >Try something like this:
  34.  
  35. >type 
  36. > xfunction:function(x:integer):integer;
  37.  
  38. >function yfunction(first,last:integer; theFunc:xFunction):integer
  39.  
  40. >Then in the procedure it should look something like:
  41. > inc(temp,theFunc(i));
  42.  
  43. >Just as though theFunc was a 'normal' function.  (It is, however, a pointer.
  44.                               ^^^^^^^^                               ~~~~~~~
  45. *NOT QUITE*, since it *MUST* be declared *FAR* (either by              ^
  46.          * function theFunc(x:integer):integer; far;       or          |
  47.          * {$F+} (* the compiler option *)                             |
  48.                                                               because of this
  49. > [..]
  50.  
  51. Similarly you can define arrays of *far-declared* funcs/procs, and thelike.
  52.  
  53. --
  54.  Hartmut Frommert, LS Dehnen, Physics, | E-Mail: <phfrom@dknkurz1.bitnet>
  55.  Univ of Constance, P.O.Box 55 60,     |     or  <phfrom@nyx.uni-konstanz.de>
  56.  D-W-7750 Constance, Germany  | + SAVE THE WHALES ! BOYCOTT NORWAY !        +
  57.  Phone: +49-(0)7531-88-3747   | + Whales R intelligent. Whale killers not.  +
  58. + Whale killing is murder. Eating whales is cannibalism. Eat whale killers. +
  59.