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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-14 17:46:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn11feed!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail Message-ID: <3F650BBE.4080107@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1063586772 24.34.139.183 (Mon, 15 Sep 2003 00:46:12 GMT) NNTP-Posting-Date: Mon, 15 Sep 2003 00:46:12 GMT Organization: Comcast Online Date: Mon, 15 Sep 2003 00:46:12 GMT Xref: archiver1.google.com comp.lang.ada:42505 Date: 2003-09-15T00:46:12+00:00 List-Id: Russ wrote: > The fact that you need five lines, a new scope, and a new variable to > do what most programmers (C, C++, Java, Perl, and Python) can do in > one simple line should tell you something. If that's what Ada > programmers call "more readable," then I'll take the "less readable" > code, thanks. You are being silly. Another common approach in Ada is to define a procedure to do the work. Now I might give an example as: procedure Inc(X: in out Integer) is begin X := X + 1; end Inc; pragma Inline(Inc); And sometimes I have done just that. But in reality, an operation like that is seldom on Integers, because of the almost ironclad style of for loops in Ada. And when it does occur, I am going to think about whether overflow can occur, and if it can what should happen on overflow. So in actual practice I have written lots of "little" Inc subroutines that ended up being a package exporting an encapsulated type. Where the package itself was several pages long including comments. Does this mean that Ada is verbose? No. Because I only had to define what should happen in all the exceptional cases associated with that type in one place. For an example, if this was part of an inventory control system, changing the count of items in stock might trigger all sorts of actions. It might be for example that increasing the number might do a check to see if some customer had that item on backorder, and if so generate a shipping order. Similarly I have also done exactly what Matt was talking about: declare N : Integer renames Item (Number).Inventory.Count; begin ... N := N + 1; ... end; But I added the elipses to indicate that ususally when you do that, the complex name would appear in several other places in that code segment, and the declare block makes it clear that that code is operating on one particular record. So the example might really become: declare N : Integer renames Item (Number).Inventory; begin -- some operations on N N.Count := N.Count + 1; -- more operations on N end; In fact, almost always when you use this idiom it is directly inside a loop: for Number in Item'Range loop declare N : Integer renames Item (Number).Inventory; begin -- some operations on N N.Count := N.Count + 1; -- more operations on N end; end loop; -- Robert I. Eachus "As far as I'm concerned, war always means failure." -- Jacques Chirac, President of France "As far as France is concerned, you're right." -- Rush Limbaugh