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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6cb2525ffbfe23ce X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Why both "with" and "use"? Date: 1999/02/23 Message-ID: #1/1 X-Deja-AN: 447651728 References: <36C5B28C.F32C43A4@jps.net> <7acj53$1vu@news3.newsguy.com> <7af68r$52o$1@platane.wanadoo.fr> <7ahq7p$s6k$1@nnrp1.dejanews.com> <7ai7p1$8kp$1@nnrp1.dejanews.com> <7akgvr$82k$1@nnrp1.dejanews.com> Organization: The Mitre Corp., Bedford, MA. Newsgroups: comp.lang.ada Date: 1999-02-23T00:00:00+00:00 List-Id: In article <7akgvr$82k$1@nnrp1.dejanews.com> robert_dewar@my-dejanews.com writes: > Well yes, especially easy, since Robert Eachus and I have > discussed this particular case many times (Robert, you > should really have let people who have NOT thought about > this before think a little longer, too bad you jumped in, > not really fair :-) If you hadn't posted on a Thursday, I would have waited longer. But our church was moving into a new building this weekend, so I didn't expect to have time to log in from home. (Or for that matter from the church. The phones lines weren't moved until late yesterday, so I could do most of the work of setting up the computers, but not check net access.) > Anyway, that should be instructive, most people find this > a surprise when they first encounter it. The classic, "It's not a bug it is a feature!" Once you understand it, you understand why any alternative would be worse, and it is one of those language features you try to avoid the dark corners of. Another is that overloading subprograms is a wonderful feature, as is overriding. But hiding a subprogram, or worse yet creating a subprogram that can't be called is bad... What's wrong with this picture? with Ada.Text_IO; procedure Puzzle is procedure My_Put(S: String; N: Integer := 1) is begin Ada.Text_IO.New_Line(Ada.Text_IO.Count(N)); Ada.Text_IO.Put(S); end My_Put; procedure My_Put(S: String) is begin Ada.Text_IO.Put(S); end My_Put; begin My_Put("Hello World!"); end Puzzle; Once you see why this won't compile, you think that it is no big deal. But it is! If during maintenance a parameter with a default is added to an outer declaration, it can cause working code not to compile. The best solution is to always avoid hiding in Ada--it doesn't help much, and can be a later maintenance problem. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...