comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: ADA - VHDL
Date: 1996/07/11
Date: 1996-07-11T00:00:00+00:00	[thread overview]
Message-ID: <4s39be$gkt@felix.seas.gwu.edu> (raw)
In-Reply-To: dewar.837036283@schonberg


In article <dewar.837036283@schonberg>, Robert Dewar <dewar@cs.nyu.edu> 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




  reply	other threads:[~1996-07-11  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-09  0:00 ADA - VHDL P. Cnudde VH14 (8218)
1996-07-09  0:00 ` Jacques Rouillard
1996-07-10  0:00 ` Paul B. Graham
1996-07-10  0:00   ` Robert Dewar
1996-07-11  0:00     ` Michael Feldman [this message]
1996-07-10  0:00   ` Laurent Gasser
1996-07-11  0:00     ` P. Cnudde VH14 (8218)
1996-07-12  0:00       ` Paul B. Graham
1996-07-11  0:00 ` Jens Hansson
1996-07-11  0:00 ` Jean-Marc Bourguet
1996-07-11  0:00 ` Robert Dewar
1996-07-15  0:00   ` Brian "Cheebie" Merchant
1996-07-16  0:00     ` Stephen A. Bailey
1996-07-16  0:00     ` P. Cnudde VH14 (8218)
1996-07-16  0:00     ` jos de laender vh14 7461
1996-07-22  0:00     ` Nick Weavers
1996-07-12  0:00 ` Jean-Marc Bourguet
1996-07-13  0:00   ` Michael Feldman
1996-07-17  0:00 ` Chris Papademetrious
replies disabled

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