home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- 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
- From: phfrom@nyx.uni-konstanz.de (Hartmut Frommert)
- Subject: Re: Functions and Procedures as Parameters
- Message-ID: <phfrom.185@nyx.uni-konstanz.de>
- Sender: usenet@eratu.rz.uni-konstanz.de
- Organization: Dept. of Physics, University of Constance
- References: <BrpxpG.351@ux1.cso.uiuc.edu> <1992Jul21.050043.7238@usenet.ins.cwru.edu>
- Date: Tue, 21 Jul 1992 08:46:24 GMT
- Lines: 47
-
- bx304@cleveland.Freenet.Edu (Jeff Epler) writes:
-
- >In a previous article, husak@ux1.cso.uiuc.edu (Stephen R. Husak) says:
-
- >>I've been trying to implement the following in TP5.5... [..]
-
- I use TP 6.0, bu think this makes no diff here..
-
- >>I want to pass a function into another function:
- >>
- >>eg -- function First(a,b: real;
- >> function test(x:integer):integer);
- >> [..]
-
- >[..]
- >I *think* that one must declare a TYPE that is a function. What you
- >have above doesn't work for the same reason that function
- >george(harry:array[1..20] of char):char; doesn't work.
-
- You're right.
-
- >Try something like this:
-
- >type
- > xfunction:function(x:integer):integer;
-
- >function yfunction(first,last:integer; theFunc:xFunction):integer
-
- >Then in the procedure it should look something like:
- > inc(temp,theFunc(i));
-
- >Just as though theFunc was a 'normal' function. (It is, however, a pointer.
- ^^^^^^^^ ~~~~~~~
- *NOT QUITE*, since it *MUST* be declared *FAR* (either by ^
- * function theFunc(x:integer):integer; far; or |
- * {$F+} (* the compiler option *) |
- because of this
- > [..]
-
- Similarly you can define arrays of *far-declared* funcs/procs, and thelike.
-
- --
- Hartmut Frommert, LS Dehnen, Physics, | E-Mail: <phfrom@dknkurz1.bitnet>
- Univ of Constance, P.O.Box 55 60, | or <phfrom@nyx.uni-konstanz.de>
- D-W-7750 Constance, Germany | + SAVE THE WHALES ! BOYCOTT NORWAY ! +
- Phone: +49-(0)7531-88-3747 | + Whales R intelligent. Whale killers not. +
- + Whale killing is murder. Eating whales is cannibalism. Eat whale killers. +
-