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,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f7a9613bbc2bd8c9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-13 22:00:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "Grein, Christoph" Newsgroups: comp.lang.ada Subject: Re: Generic default parameters Date: Tue, 14 May 2002 06:57:52 +0200 (MET DST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 1021352404 11824 137.194.161.2 (14 May 2002 05:00:04 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 14 May 2002 05:00:04 +0000 (UTC) Return-Path: X-Authentication-Warning: mail.eurocopter.com: uucp set sender to using -f Content-MD5: t8YWOsVbZs0FGvj0dQguig== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk X-Reply-To: "Grein, Christoph" List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:23994 Date: 2002-05-14T06:57:52+02:00 > > 6. A more liberal matching of actual subprograms against formal ones. > > If some parameters of the actual subrogram have defaults, then they > > can be absent in the formal one. > > > > generic > > with procedure Put (Item : in Object) is <>; > > package Foo ... > > > > Then an instantiation with Integer_IO.Put: <-------- #2 > > > > procedure Put > > ( Item : in Num; > > Width : in Field := Default_Width; > > Base : in Number_Base := Default_Base > > ); > > > > should be legal. > > I like this. I don't see how it could be a problem. I do see problems with this proposal. First of all it would be a major upwardly incompatible change and break old code - a NONO for the ARG. Imagine Ada95 code that defines procedure Put (Item: in Num) is -- #1 begin Put (Item, Default_Width, Default_Base); -- the Int_IO one, #2 end Put; package Foo_Inst is new Foo; Currently this is OK since only #1 matches. With this proposal, #1 and #2 would be candidates (assuming the latter is directly visible), so the compiler would not know which to take. This breakes old code. OK, you could complicate the rules by stating that if there is a match without defaults, this one is preferred, then it would not break old code. But then you would introduce another case where adding or removing a declaration silently changes the code. We surely do not want another such rule. [Beaujolais effect, where adding and removing a use clause changes the legal behaviour, has been removed from Ada with the 95 standard. Sadly enough, a new effect has been introduced, where adding and removing a with clause can now change the legal behaviour (think of child packages) - isn't this called the Ripple effect? We really do not want another such effect. If you think more closely about it, such a preference rule would reintroduce the Beaujolais effect.] This being the case, it seems useless to discuss how matching rules for subprograms with defaulted parameters should be defined - they are not so obvious for me.