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,16e06ab8237bab07 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.84.234 with SMTP id c10mr1347517wiz.4.1351391117541; Sat, 27 Oct 2012 19:25:17 -0700 (PDT) Path: q13ni70614wii.0!nntp.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.panservice.it!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Is this a bug in Ada.Numerics? Date: Sun, 21 Oct 2012 05:39:09 +0200 Organization: A noiseless patient Spider Message-ID: <87r4oscx42.fsf@ludovic-brenta.org> References: <8391f2d1-b4c7-4b12-bc16-1419a1aa9739@googlegroups.com> <87wqykd1wv.fsf@ludovic-brenta.org> <0360d84c-ef42-4107-b837-4063da273ad8@googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="d2af1a6e986227e7043ad7a0efc7c4bd"; logging-data="16594"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fClInweakW80b7+Fuc9sH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:XVY6HLFPhr9pgsXa4Tmj1V5lLsk= sha1:jkfhtnwH7RlsYsuZp1RDEp/MMSk= Content-Type: text/plain; charset=us-ascii Date: 2012-10-21T05:39:09+02:00 List-Id: Leo Brewin writes: > But having digested your answer I'm still a bit confused (sorry). Here > is the "procedure" version of the above package, > > with Ada.Numerics.Generic_Complex_Types; > with Ada.Numerics.Generic_Complex_Elementary_Functions; > > procedure foo is > > type Real is digits 18; > > package Complex_Types is new > Ada.Numerics.Generic_Complex_Types (Real); > > use foo.Complex_Types; > subtype Complex is foo.Complex_Types.Complex; > > procedure bar (z : in out Complex); > > package Complex_Maths is new > Ada.Numerics.Generic_Complex_Elementary_Functions (Complex_Types); > > procedure bar (z : in out Complex) is > begin > z := Complex'(Re(z),0.0); > end bar; > > begin > null; > end foo; > > This does compile and yet (by my reading of your reply) the "use foo" > and "subtype complex" lines should introduce two distinct versions of > Complex and thus should produce a compiler error. The difference is that, in the procedure, the subtype Foo.Complex is declared in the immediate scope where Complex_Maths is declared, so it hides Foo.Complex_Types.Complex, so there is no ambiguity anymore. You get the same effect with the package if you move the declaration of Complex_Maths to the package spec. These rules are quite subtle and the error messages from GNAT less than helpful. Maybe that's why Ada has a reputation for being "difficult to learn". -- Ludovic Brenta.