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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7f5c70275787af8 X-Google-Attributes: gid103376,public From: "Steve Doiel" Subject: Re: Ada vs Delphi? Date: 1999/08/15 Message-ID: <37b6db54.0@news.pacifier.com>#1/1 X-Deja-AN: 513040738 References: <37ab421a.5414989@news.total.net> <37ab8bd1.0@news.pacifier.com> <37ae1fc8.653954@news.clara.net> <37AE980F.15E6A15C@maths.unine.ch> <37b12a3f.43564067@news.total.net> <37B27FE8.6E09569E@Maths.UniNe.CH> <37b54516.54588055@news.total.net> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Trace: 15 Aug 1999 08:23:00 PST, 216.65.140.140 X-MSMail-Priority: Normal Reply-To: "Steve Doiel" Newsgroups: comp.lang.ada Date: 1999-08-15T00:00:00+00:00 List-Id: [snip] > > Getting back to my first example: > > <<< > for n1:= -128 to 127 > for n2:= -128 to 127 > begin > sum:= n1 + n2; > ... > end; {for} > >>> > > how would you declare variables n1, n2, and sum in Ada? In Ada you need not declare the loop variables. If wish to you can as I have done in the example below (a sample program which does compile): procedure ngdemo is type aByteRange is range -128..127; sum : Integer; begin for n1 in aByteRange range -128 .. 127 loop for n2 in aByteRange range -128 .. 127 loop sum := Integer( n1 ) + Integer( n2 ); -- If you try to compile using just -- sum := n1 + n2; -- you get a compile time error: -- expected type "Standard.integer" -- found type aByteRagne defined at line 3 end loop; end loop; end ngdemo; In this example I have forced the indexes n1 and n2 to be of a type that ranges from -128 to 127. Clearly the intermediate result for calculating sum would have to exceed this range, so I cast both n1 and n2 to integer before performing the addition. This is likely what is intended by the example. But... I am making an assumption about casting the type of n1 and n2 to Integer. Ada does not make this assumption. As a matter of fact Ada makes no assumptions about how you wish to operate or convert between types. That is in my opinion one of its advantages over Delphi. SteveD