comp.lang.ada
 help / color / mirror / Atom feed
From: "Vincent Marciante" <vmarciante@decilog.com>
Subject: Re: Is this a bug in Ada.Numerics?
Date: Tue, 23 Oct 2012 11:48:56 -0400
Date: 2012-10-23T11:48:56-04:00	[thread overview]
Message-ID: <-tidnSXVvpz6IRvNnZ2dnUVZ_g6dnZ2d@earthlink.com> (raw)
In-Reply-To: 87r4oscx42.fsf@ludovic-brenta.org

"Ludovic Brenta" <ludovic@ludovic-brenta.org> wrote in message 
news:<87r4oscx42.fsf@ludovic-brenta.org>...

> Leo Brewin <leo.brewin@internode.on.net> 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.





This is a type of comment that AdaCore's Robert Dewar really likes to 
address.
I think that there is good chance that an improvement would be made in GNAT
to address this issue if you or the original poster send a report to 
AdaCore.



Vinny





> Maybe that's why Ada has a reputation for being "difficult to

> learn".

>

> -- 

> Ludovic Brenta.

. 





  parent reply	other threads:[~2012-10-23 15:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21  0:37 Is this a bug in Ada.Numerics? Leo Brewin
2012-10-21  1:54 ` Yannick Duchêne (Hibou57)
2012-10-21  2:39   ` Leo Brewin
2012-10-21  1:55 ` Ludovic Brenta
2012-10-21  2:32   ` Leo Brewin
2012-10-21  3:39     ` Ludovic Brenta
2012-10-21  3:54       ` Leo Brewin
2012-10-21  8:59       ` Georg Bauhaus
2012-10-23 15:48       ` Vincent Marciante [this message]
2012-10-23 22:52       ` Leo Brewin
2012-10-23 23:09         ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox