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.8 required=5.0 tests=BAYES_00,INVALID_MSGID, SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e03bc978c29ea47 X-Google-Attributes: gid103376,public X-Google-Thread: 1089ad,2e03bc978c29ea47 X-Google-Attributes: gid1089ad,public From: mfeldman@seas.gwu.edu (Michael Feldman) Subject: Re: ADA - VHDL Date: 1996/07/11 Message-ID: <4s39be$gkt@felix.seas.gwu.edu>#1/1 X-Deja-AN: 167820841 references: <31E2391F.A16BEBD@sh.bel.alcatel.be> <4s09jq$ddn@srvr1.engin.umich.edu> organization: George Washington University newsgroups: comp.lang.ada,comp.lang.vhdl Date: 1996-07-11T00:00:00+00:00 List-Id: In article , Robert Dewar wrote: >Paul says >"VHDL has ascending and descending ranges. Ada has only ascending ranges. >Unconvincing -- sure you will always find someone who finds X more >"convenient and understandable" than Y (and of course someone else >who finds Y more "convenient and understandable" than X). I do not >find this a good basis for a gratuitous change like the above (I >would find a change in either direction gratuitious), and indeed >it seems that some of the differences between VHDL and Ada are >not justified, they seem to be cases where personal taste has >intruded unnecessarily. An important point here is that the ascending range syntax allows a named range to be used for counting either up or down: type Days is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); (or any integer range as well; I just like enumerations:-)) Going forward in the week, one can just write for Day in Days loop... going backward, one can just write for Day in reverse Days loop... The real advantage here is that you can avoid "magic numbers" in your code, so that if - to carry my stupid Days example further - we changed the enumeration values to French ones - type Days is (lundi, mardi, mercredi, jeudi, vendredi, samedi, dimanche); the rest of your code is unchanged. We could even declare an array type type Weekly_Pay is array (Days) of Float; (say) and an object ThisWeek: Weekly_Pay; and the array index, the forward loop, and the backward loop, are all consistent and immune from inconsistent code changes. This is a real improvement over the Pascal loop syntax, which VHDL borrowed and which has no way to use the named range. Ada syntax is remarkably regular in this regard. (Yes, I know - there's no "by" field in an Ada for statement. No free lunch.:-)) Mike Feldman