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,1ea19776e3073a96 X-Google-Attributes: gid103376,public From: Jean-Marc Bourguet Subject: Re: C/C++ programmer giving Ada95 a chance -- writing an emulator. Date: 2000/03/28 Message-ID: <8bpqga$8sh$1@nnrp1.deja.com>#1/1 X-Deja-AN: 603315017 References: <38e148e2.5089627@news.shreve.net> <38E05DF5.D9AEC67A@research.canon.com.au> X-Http-Proxy: 1.1 sj-netcache (NetCache 4.0R2D6), 1.0 x30.deja.com:80 (Squid/1.1.22) for client 158.140.208.29, 158.140.3.201 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue Mar 28 08:29:08 2000 GMT X-MyDeja-Info: XMYDJUIDbourguet Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (X11; I; SunOS 5.5.1 sun4u) Date: 2000-03-28T00:00:00+00:00 List-Id: In article <38E05DF5.D9AEC67A@research.canon.com.au>, Geoff Bull wrote: > > jross wrote: > > > > C/C++ is prime for such a low level application. How about Ada? > > Anything you can write in C you can more or less directly translate > to Ada. But I'd warn against trying to put a C++ design in Ada. Success would perhaps proove something -- but I do not know what -- failure surely nothing more that Ada is not a better syntax for C++. You'll have problem with features not present in Ada, and never think about using features not present in C++ (in you exemple, do you have though about using taks to for the different parts of the processor and the peripherals? I'd do this more rapidly in Ada than using threads in C++) > > My first question is how do you define and write a dispatching > > mechanism as you would in C++ using function pointers in a table for > > execution speed efficiency, like this: > > > > The following is a direct translation of your code: No, it isn't. For one, the original C++ made use of pointers to member functions. Having little used of access to procedures, I do not know if the equivalent is possible -- calling throw the access would need to trigger a dispatching call (James, this term has a technical meaning in Ada); I think a wrapper procedure would be needed to achieve the equivalent (I'm supposing that the TCpu class not showed declare the Op_xx as virtual functions). In either case, I know too little about your design (what is the TCpu class for) and your design goals (what where you trying to achieve by introducing it) to give a good translation of your code. The correct equivalent of a class in C++ may be a package or a non tagged type or a tagged type. Even for TACpu I can not tell which one is better. -- Jean-Marc Sent via Deja.com http://www.deja.com/ Before you buy.