From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a44046be0e2c612d X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Multi-dimensional Array of Functions ? Date: 2000/05/05 Message-ID: <8euje5$rfd$1@nnrp1.deja.com>#1/1 X-Deja-AN: 619574209 References: <169b2ded.062ddfc5@usw-ex0109-068.remarq.com> X-Http-Proxy: 1.0 x22.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Fri May 05 13:47:55 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) Date: 2000-05-05T00:00:00+00:00 List-Id: In article <169b2ded.062ddfc5@usw-ex0109-068.remarq.com>, John O'Malley wrote: > I am a newbie to ada and I am looking for an example of an > array of functions. The project I am currently working on > has a procedure which is a gaint case statement with nested > cases that make function calls. This procedure is > unreadable and could easily be reduced by 99% by using a > multidimensional array containing pointers to functions. Often the case statement can be removed entirely using dynamic dispatching. See if there's a way to make a tagged type with a predefined function and one child type per case branch. Then you can just have Ada dispatch to the appropriate function based on which subtype of the parent tagged type was passed in. > I know how to create an array of pointers to functions in C > and I was wondering if this is even possible in ada 83 or > 95. If it is possible, do all the functions in the array > have to be formatted the same (i.e same pass and return > parameters)? Any help and/or examples would be appreciated. Its possible in Ada 95. Get out your handy-dandy Ada 95 book (whichever one you are using) and look up access to subprogram types. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.