comp.lang.ada
 help / color / mirror / Atom feed
From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com>
Subject: Re: Language pitfalls (was Re: FORTRAN bug)
Date: Wed, 16 Dec 92 08:38:31 CST	[thread overview]
Message-ID: <9212161438.AA15124@efftoo.boeing.com> (raw)

visicom!rlk@nosc.mil  (Bob Kitzberger) sez:

>	5. Avoid the USE clause; consider RENAMES instead.

Why the heck are people teaching this?  I mean, do you really *like*
code that looks like:

         if ((Environment_Messages.Mode_Selection_Message_Record.
            Age_Of_This_Message = Application_Layer_Services.New_Message) and
            (Environment_Messages.Data_In_Mode_Selection_Message_Record.
            Modules_Affected (Global_Types.Environment) = Global_Types.On))
          then

or whatever?  And don't forget this crap that you have to put at the
beginning:

   function "=" (L, R: Application_Layer_Services.Message_Ages) return Boolean
      renames Application_Layer_Services."=";

The above (well, slightly less awful -- I cheated and have a package-
body-scope USE clause for Global_Types and I have a constant RENAMES
for New_Message) is from actual production code, but remember,
I have no life ;-)

Nobody who is interested in getting the job done and getting out of
the office at the end of the day is going to want to write (or read)
code that looks like this.  Result?  192 USE clauses in every package
body "just to get it going".  But somehow there's never time to
rework those bodies.

Isn't it better instead to teach the locally scoped USE clause:

	 declare                           -- for the following IF
           use Environment_Messages;       -- Mode_Selection_Message_Record
           use Application_Layer_Services; -- Message_Age
           use Global_Types;               -- Mode_Sel..Record types
         begin
            if ((Mode_Selection_Message_Record.
               Age_Of_This_Message = New_Message) and
               (Data_In_Mode_Selection_Message_Record.
               Modules_Affected (Environment) = On))
             then
               ...
            end if;
         end;

Why isn't this being taught?  Was it at one time broken in the holy
VAX Ada?  Or is there some other reason I'm not thinking of?

BTW, to forstall a possible objection about scoping it over a 2-page
IF, I personally believe that if you have a 2-page IF, you've got
a more serious problem than just a hard-to-read USE clause!

p.s., sorry about the look of the IF statement; old FORTRAN habits
die hard.
+-------------------------------+--------------------------------------+
| Bob Crispen                   |   Who will babysit the babysitters?  |
| crispen@foxy.boeing.com       +--------------------------------------+
| (205) 461-3296                |Opinions expressed here are mine alone|
+-------------------------------+--------------------------------------+

             reply	other threads:[~1992-12-16 14:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-16 14:38 crispen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-12-17 18:48 Language pitfalls (was Re: FORTRAN bug) John Halper
1992-12-17 14:18 Terry J. Westley
1992-12-17  1:31 Robert I. Eachus
1992-12-16 20:59 John Bollenbacher
1992-12-16 20:02 Julian C . Lander
1992-12-16 17:38 Bob Kitzberger
1992-12-16 17:27 Mark A Biggar
1992-12-16 16:32 olivea!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!asuvax!ennews
1992-12-16  1:22 Robert I. Eachus
1992-12-15 20:35 news.centerline.com!noc.near.net!inmet!spock!stt
1992-12-15 18:08 Richard Pattis
1992-12-15 15:47 Michael Feldman
1992-12-15 14:55 David Emery
1992-12-15 13:55 enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!news.lth.se!dag
1992-12-14 21:57 Bob Kitzberger
replies disabled

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