comp.lang.ada
 help / color / mirror / Atom feed
From: Ashley Deas Eachus <rieachus@earthlink.net>
Subject: Re: bitwise comparators
Date: 2000/02/05
Date: 2000-02-05T00:00:00+00:00	[thread overview]
Message-ID: <389C4F0D.E5541B98@earthlink.net> (raw)
In-Reply-To: Pine.BSF.4.21.0001170845160.20312-100000@shell5.ba.best.com

Brian Rogoff wrote:

> C is also my primary language, and at the risk of annoying Robert Eachus :-),
> let me add "nested subprograms" to your list. And the ability to have local
> arrays whose dimension depends on a local or parameter. And ...

     No annoyance, or maybe a little in the terminology. ;-)  I specifically
distinguished between nested procedures and nested functions.   But the fact that
most nested  procedures in Ada indicate design flaws does not mean that nested
procedures are not a very powerful feature in Ada.   Quite the opposite.

    My complaint, if you can call it that, it that nested procedures in Ada are a
great design abstraction.  However, when the design is realized, almost all such
procedures should be transformed into more appropriate constructs.  Don't use a
sledgehammer to swat flies.  Of course, many of the abstractons that the nested
procedure can be specialized to are also powerful.  In fact, nested generic
procedures are more like an M1A1 tank.  Unlike nested procedures however, they are
not overused...

> I agree with Alexander that Ada is a larger language and to learn all of
> its features is much harder than to learn all of the features of C, but
> I've found it a much more rewarding language as well. If you're
> comfortable with C, just start with the C level subset of Ada and add
> knowledge as you need it. With Ada 95, you really do have all of the
> features of C worth having.

       Ada was designed to favor readers over writers, and a lot of the
"duplicate" features are for just that purpose--to allow the author to better
communicate his intent to the reader of the program.  Part of the pressure on
authors to favor the reader is that code that sends the wrong message looks ugly
to good Ada programmers, so you will see lots of discussion here of  the "best"
way to implement some abstraction, even though all of the proposed language will
probably generate identical machine code.   So take discussions here about while
loops vs. exit statements--and my comments about nested procedures--with a large
grain of salt.

       Back to the original topic,  I would probably use an array of Booleans as
the best representation of the original problem:

        type Register is array(1..32) of Boolean;
        for Register'size use 32;
        Some_Register: Register;
        for Some_Register'Address use ...;
        pragma Volitile(Some_Register);
        constant Low_Order_Bit := ...;
....
        loop
           -- setup code
         exit when Some_Register(Low_Order_Bit);
           -- functional code
         end loop;

         or if you prefer:

         -- setup code
         while not Some_Register(Low_Order_Bit)
         loop
            -- functional code
            -- setup code
         end loop;

         As you can see, the exit when version is better when there is significant
setup to be done for the test--the traditional loop and a half, and the while loop
is cleaner if there is no setup required.





  reply	other threads:[~2000-02-05  0:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-15  0:00 bitwise comparators Alexander Van Hecke
2000-01-15  0:00 ` David C. Hoos, Sr.
2000-01-16  0:00 ` Jeff Carter
2000-01-16  0:00 ` Bryce Bardin
2000-01-16  0:00 ` DuckE
2000-01-17  0:00   ` Alexander Van Hecke
2000-01-17  0:00     ` Jeff Carter
2000-01-17  0:00       ` Alexander Van Hecke
2000-01-17  0:00         ` David Starner
2000-01-17  0:00           ` Alexander Van Hecke
2000-01-17  0:00             ` David Starner
2000-01-18  0:00             ` Fraser
2000-01-18  0:00               ` Bertrand Augereau
2000-01-19  0:00                 ` Ted Dennison
2000-01-19  0:00                   ` Marin D. Condic
2000-01-19  0:00                     ` Ted Dennison
2000-01-18  0:00             ` Preben Randhol
2000-01-18  0:00           ` Ted Dennison
2000-01-17  0:00         ` Gautier
2000-01-17  0:00           ` Alexander Van Hecke
2000-01-17  0:00             ` David Starner
2000-01-18  0:00             ` Gautier
2000-01-18  0:00           ` Ted Dennison
2000-01-18  0:00         ` Jeff Carter
2000-01-18  0:00           ` Keith Thompson
2000-01-19  0:00             ` Ole-Hjalmar Kristensen
2000-01-19  0:00             ` Jeff Carter
2000-01-19  0:00               ` Keith Thompson
2000-01-19  0:00               ` David Starner
2000-01-19  0:00             ` Gisle S�lensminde
2000-01-18  0:00         ` Pascal Obry
2000-01-21  0:00         ` Ada vs. C/C++ (was re: bitwise something-or-other) Mark Lundquist
2000-01-21  0:00           ` Mark Lundquist
2000-01-24  0:00           ` Hyman Rosen
2000-01-17  0:00     ` bitwise comparators David C. Hoos, Sr.
2000-01-17  0:00     ` Gautier
2000-01-18  0:00       ` Keith Thompson
2000-01-19  0:00         ` Ole-Hjalmar Kristensen
2000-01-17  0:00     ` Matthew Heaney
2000-01-17  0:00     ` tmoran
2000-01-17  0:00     ` Mike Silva
2000-01-17  0:00       ` Brian Rogoff
2000-02-05  0:00         ` Ashley Deas Eachus [this message]
2000-02-05  0:00           ` Jeff Carter
2000-02-06  0:00           ` Andy
2000-02-07  0:00           ` Brian Rogoff
2000-02-09  0:00             ` Robert Iredell Eachus
2000-01-17  0:00       ` Alexander Van Hecke
2000-01-17  0:00         ` Gautier
2000-01-17  0:00         ` David Starner
2000-01-17  0:00         ` Mike Silva
2000-01-18  0:00           ` Charles Hixson
2000-01-18  0:00     ` DuckE
2000-01-18  0:00     ` Ted Dennison
2000-01-16  0:00 ` Matthew Heaney
replies disabled

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