From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=BAYES_00,FROM_NO_USER autolearn=no autolearn_force=no version=3.4.5-pre1 Date: Wed, 16 Dec 92 08:38:31 CST From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com> Subject: Re: Language pitfalls (was Re: FORTRAN bug) Message-ID: <9212161438.AA15124@efftoo.boeing.com> List-Id: 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| +-------------------------------+--------------------------------------+