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: Robert Dewar Subject: Re: C/C++ programmer giving Ada95 a chance -- writing an emulator. Date: 2000/03/29 Message-ID: <8bsmki$f0q$1@nnrp1.deja.com>#1/1 X-Deja-AN: 603800094 References: <38e148e2.5089627@news.shreve.net> <38E05E84.BB5507FC@gmx.net> <8bqoeh$9gs$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x33.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Mar 29 10:41:23 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-03-29T00:00:00+00:00 List-Id: In article , "James S. Rogers" wrote: > Although the original author of this thread used the term > dispatching, his description of what he wants does not really > want dispatching. I disagree. Yes, he does not know to think at that abstraction level, but it is completely appropriate to his problem. > He wants to execute a procedure associated with a particular > opcode value, not based upon a separate type. But dynamic polymorphism is all about associating types with values, and having separate types for the different opcodes would likely give a far clearer, higher level, more abstract, and just as efficient expression of his intent. > He also did not want to use any form of > case statement to determine the procedure to execute. This > rules out the > use of a discriminated record. Now one can ask *why* he did not want to use a case statement, and the answer has nothing to do with case statements, but rather with thoughts about how they are likely implemented. Note that access to procedures could perfectly well be implemented using case statements, and indeed such an implementation would be attractive in a safety critical environment where indirect calls are not permitted at the object level. Equally case statements are typically implemented using indirect jumps and may well be much more efficient than the use of access to procedures. > Show me how you will design a hierarchy of tagged types > differentiated only by values of discrete type. I have not > yet seen that trick. Not clear what you mean at all here. The point is to replace the "values of discrete type" by not a hierarchy, but rather a flat tree of subtypes. What we have here is a classic case of confusing 1. high level abstract design 2. low level language solutions 3. concern about efficiency of generated code All three are quite valid in context, but often you find people worrying about 3. when they should be worrying about 1. We really can't tell what the right advice is in this situation because all we are presented with is a low level solution and associated (but slightly bogus) concerns with efficiency. We really have no idea what the high level problem is. It might or might not be the case that the use of tagged types is an improvement (there are plenty of cases where tagged types and OO stuff in general is horribly abused after all) Sent via Deja.com http://www.deja.com/ Before you buy.