comp.lang.ada
 help / color / mirror / Atom feed
* Re: how to do this in Ada?
@ 1990-03-13 18:56 westley
  1990-03-15 16:11 ` Thomas Vachuska
  1990-03-15 16:40 ` RCAPENER
  0 siblings, 2 replies; 3+ messages in thread
From: westley @ 1990-03-13 18:56 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1990-03-15 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-03-13 18:56 how to do this in Ada? westley
1990-03-15 16:11 ` Thomas Vachuska
1990-03-15 16:40 ` RCAPENER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox