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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ea19776e3073a96 X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: C/C++ programmer giving Ada95 a chance -- writing an emulator. Date: 2000/03/30 Message-ID: #1/1 X-Deja-AN: 604471984 References: <38E2DC8A.45AE7226@research.canon.com.au> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 954444238 206.170.2.185 (Thu, 30 Mar 2000 11:23:58 PST) Organization: SBC Internet Services NNTP-Posting-Date: Thu, 30 Mar 2000 11:23:58 PST Newsgroups: comp.lang.ada Date: 2000-03-30T00:00:00+00:00 List-Id: > Here's one way to use dispatching on tagged types ... > Op_Table : array (Opcode) of Op_Root > := (Op_Root (O0), > Op_Root (O1), > Op_Root (O2), > Op_Root (O3), > others => OU > ); > ... > Func (Op_Root'Class (Op_Table (IR))); > The main loop, on a sparc with gnat 3.12p -gnatp -O3, is 9 instructions It also works with Gnat 3.12p NT. But both ObjectAda and Janus print a series of "undefined opcode". It seems to me that is actually the correct behavior, since Op_Table is a table of Op_Root, not a table of Op_Root'class. I'd be inclined to report this as a Gnat error. As alternatives, you might make Op_Table a table of access-to-Op_Root'class or use a "case statement IR is". The latter, of course, is explicitly what you were trying to avoid. > I don't think it is any clearer or better than my original. Agreed. It's slower, more complex, and, it seems to me, has no benefits.