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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,556e5b18154df788 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.157.1 with SMTP id z1mr11271883qaw.8.1364939984161; Tue, 02 Apr 2013 14:59:44 -0700 (PDT) MIME-Version: 1.0 Path: v17ni20420qad.0!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.bbs-scene.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Interresting, possibly buggy behavior in GNAT generics w/ expression function. Date: Fri, 29 Mar 2013 20:04:28 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1364605479 9448 69.95.181.76 (30 Mar 2013 01:04:39 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 30 Mar 2013 01:04:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2013-03-29T20:04:28-05:00 List-Id: "Simon Wright" wrote in message news:lysj3eir9b.fsf@pushface.org... > In Generic_Attribute_Set, you have two Image functions: > > function Image(Value : Attribute_Values) return String > > (Attribute_Values is a generic formal scalar) and > > function Image(Value : Positive) return String > > and you instantiate the package with Attribute_Values => Integer. > > What happens when you change the second Image's parameter to Integer is > that GNAT chooses the wrong Image to call! Something is wrong with this description, because as you have described it, any call on Image should be ambiguous and thus illegal. Specifically: generic type Attribute_Values is (<>); package Test_It is function Image(Value : Attribute_Values) return String; function Image(Value : Positive) return String; end Test_It; package A_Test is new Test_It (Integer); This instantiation is legal. However, a call like A_Test.Image (10); is ambiguous, because there is no possible way to know which routine should be called. It's certainly not possible to call the *wrong* one here, because they are exactly the same for resolution purposes. Now, if they have different parameter names: function Image (Val : Positive) return String; then A_Test.Image (Val => 10); -- Should work. A_Test.Image (10); -- Still ambiguous. If GNAT is allowing these calls, *that's* the bug; what happens when you change subtypes is irrelevant. Perhaps you guys would like to do as you are always griping to others and provide a complete enough example to see what you are really talking about??? Randy.