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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!snorkelwacker!usc!brutus.cs.uiuc.edu!rpi!image.soe.clarkson.edu!sunybcs!planck!hercules.uucp!westley From: westley@hercules.uucp Newsgroups: comp.lang.ada Subject: Re: how to do this in Ada? Message-ID: <1990Mar13.185638.16143@planck.uucp> Date: 13 Mar 90 18:56:38 GMT Sender: news@planck.uucp (Usenet News) Reply-To: westley%hercules@planck.UUCP (Terry J. Westley) Followup-To: comp.lang.ada Organization: Calspan Corporation ATC Buffalo, NY List-Id: With apologies to those of you who already saw this in comp.software-eng -- I didn't edit the newsgroup header properly and wanted this to go into comp.lang.ada: In article <1771@awdprime.UUCP> sanders@sanders.austin.ibm.com (Tony Sanders) writes: >How do you do this in ADA? > > switch(n) { > case 0: > count++; > case 1: > ocount++; > case 2: > printf("%d %d\n",count,ocount); > break; > default: > printf("unknown n\n"); > break; > } > >See how I left out the breaks on purpose. > >In ADA you wouldn't be able to do this without duplicating either the >case-expression (they aren't always simple numbers) or the statements. > If the code is short enough that I can easily see any errors, I *would* duplicate it; if its not, I'd use a subprogram. In either case, we are talking about micro-efficiency here. Algorithm and data structure design (and ease of expression thereof) are much more important to the development and maintenance of good software than this kind of concern for what language is better for low-level efficiency. Personally, I find Ada to be especially good for this (and yes, I have used C extensively). Your mileage may vary. ---------------- Different topic follows: ------------------------- Now, for an Ada topic I have been struggling with and would love to hear advice from those who have done the equivalent in Ada. I don't want to hear from those who tell me to do it in C. We are building a real-time radar simulation on a distributed network of ~35 Sun workstations and ~35 68030 CPU boards (Motorola MVME147 specifically). Parts of the network will be Ethernet; the backbone will be FDDI. Now, for my question: I have approximately 200 unique messages that are transmitted over the net among all the various nodes. How do I send a particular Ada object of some arbitrary record type to another node while: 1) preserving strong typing -- I don't want to have to convert everything to some common structure such as an array of bytes 2) reducing messages to the smallest possible size -- I need to reduce the net traffic as much as possible -- as you know, there are numerous challenges relating to using variant record structures while trying to achieve this goal 3) avoiding giving global visibility to all message types to all program units I started out by writing a LAN interface package as a generic patterned after sequential_io. You instantiate it with the particular variant record structure that applies to the sender and receiver of that particular data. I also imported a function to determine the size of a particular record so that I wouldn't always be sending the maximum size of the record. The major problem with this is that I have many different combinations of messages to be sent to each destination. Here is a much simplified example of this problem. Suppose I have three elements that need to communicate: Element # Runs on Processor Needs message types --------- ---------------- ------------------- 1 A a, b, c 2 B b, c 3 C a, c I could build a variant record structure of message types a, b, and c. However, then Element 2 and 3 have visibility to message types they have no business seeing. I can't build three variant records (a-b-c, b-c, and a-c) because the record types will now be incompatible. Any ideas? Terry J. Westley Arvin/Calspan Advanced Technology Center P.O. Box 400, Buffalo, NY 14225 acsu.buffalo.edu!planck!westley@hercules Terry J. Westley Arvin/Calspan Advanced Technology Center P.O. Box 400, Buffalo, NY 14225 acsu.buffalo.edu!planck!westley@hercules