home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bx304
- From: bx304@cleveland.Freenet.Edu (Jeff Epler)
- Subject: Re: Functions and Procedures as Parameters
- Message-ID: <1992Jul21.050043.7238@usenet.ins.cwru.edu>
- Sender: news@usenet.ins.cwru.edu
- Nntp-Posting-Host: cwns16.ins.cwru.edu
- Reply-To: bx304@cleveland.Freenet.Edu (Jeff Epler)
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- References: <BrpxpG.351@ux1.cso.uiuc.edu>
- Date: Tue, 21 Jul 92 05:00:43 GMT
- Lines: 41
-
-
- In a previous article, husak@ux1.cso.uiuc.edu (Stephen R. Husak) says:
-
- >I've been trying to implement the following in TP5.5... Could someone
- >either clue me in or tell me if it is possible.
- >
- >I want to pass a function into another function:
- >
- >eg -- function First(a,b: real;
- > function test(x:integer):integer);
- >
- > { rest of function follows }
- >
- >I know this is implemented in some versions of Pascal. Is this possible
- >in TP and if it is what am I doning wrong...???? Thanks!
- >
-
- I believe so. But, this is from memory and my copy of TP isn't handy.
-
- 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.
-
- 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. And whenever someone talks of pointers, I get hives. It
- reminds me of when I tried to learn C. :)
- --
- |Jeff Epler Additions Welcome ;-) >{8-) |
- | :) (=( =-] (-= Celebrating the variety of faces =-> :^) {-= |-) (: |
- | Lincoln, Nebraska|
-