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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: ambiguous expression (cannot resolve "Put") Date: Sat, 27 Jul 2019 10:28:04 +0200 Organization: Adalog Message-ID: References: <64bf79fa-b330-416f-9deb-de3f0830d994@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 27 Jul 2019 08:28:04 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="d85c5c9d824fbcecb43a7edfebc9df98"; logging-data="3790"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uNW03L0kJtLiyB4RVsYDZ" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cancel-Lock: sha1:2rVKR6nLXbmecYzJDDnXxEQa/C4= In-Reply-To: <64bf79fa-b330-416f-9deb-de3f0830d994@googlegroups.com> Content-Language: fr Openpgp: preference=signencrypt Xref: reader01.eternal-september.org comp.lang.ada:56972 Date: 2019-07-27T10:28:04+02:00 List-Id: Le 27/07/2019 à 09:32, cryintothebluesky@gmail.com a écrit : > Hi, could anyone suggest how to print 'Size attribute for various integers? There seems to be an issue with overloaded Put() function. Not sure why only 'Size attribute causes this issue, other attributes like 'First and 'Last seem OK. I suppose I could do something like Ada.Integer_Text_IO.Put() and Ada.Short_Integer_Text_IO.Put() but this doesn't look very nice. > > > with Ada.Text_IO; use Ada.Text_IO; > with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; > with Ada.Short_Integer_Text_IO; use Ada.Short_Integer_Text_IO; > > procedure Integer_Types is > begin > Put("Integer'Size "); Put(Integer'Size); New_Line; > Put("Integer'First "); Put(Integer'First); New_Line; > Put("Integer'Last "); Put(Integer'Last); New_Line; > > Put("Short_Integer'Size "); Put(Short_Integer'Size); New_Line; > Put("Short_Integer'First "); Put(Short_Integer'First); New_Line; > Put("Short_Integer'Last "); Put(Short_Integer'Last); New_Line; > end Integer_Types; > Integer'First is of type Integer; therefore overloading resolution can resolve the Put to the one on Integer. However, Integer'Size is of type Universal_Integer, i.e. the actual type is determined from context. Since you have two acceptable contexts, it is ambiguous. You can either qualifie the expression: Integer'(Integer'Size) or specify explicitely which Put you want: Integer_Text_IO.Put (Integer'Size); -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr