comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Is this a bug in Ada.Numerics?
Date: Sun, 21 Oct 2012 03:54:28 +0200
Date: 2012-10-21T03:54:28+02:00	[thread overview]
Message-ID: <op.wmh982j7ule2fv@cardamome> (raw)
In-Reply-To: 8391f2d1-b4c7-4b12-bc16-1419a1aa9739@googlegroups.com

Hi,

Just reading your snippet (not tried to compile)

Le Sun, 21 Oct 2012 02:37:36 +0200, Leo Brewin  
<leo.brewin@internode.on.net> a écrit:

> In the course of my dabblings in Ada I've come across a curious  
> "behaviour" that seems to me, with my limited knowledge of Ada, to be a  
> bug.
>
> Here is a simple package spec
>
>    with Ada.Numerics.Generic_Complex_Types;
>    with Ada.Numerics.Generic_Complex_Elementary_Functions;
>
>    package 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);
>   end foo;

When you do “use foo.Complex_Types;”, you introduce from then in the  
current scope, all definitions from “foo.Complex_Types”. (by the way, you  
don't need “use foo.Complex_Types;”, as “use Complex_Types;” would be  
enough). This means that “foo.Complex_Types.Complex” [1] is introduced in  
the scope, so there is a clash with the subtype you define right after.  
May be you did not understood what exactly “use” do?

[1] See [G.1.1 Complex  
Types](http://www.adaic.org/resources/add_content/standards/05rm/html/RM-G-1-1.html),  
which contains the following:

     type Complex is […]


> and the package body
>
>    package body foo is
>
>       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;
>
>    end foo;

Not part of the case, but here, you are instantiating a generic package  
which you don't use (must be an error).


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



  reply	other threads:[~2012-10-28  2:25 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) [this message]
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
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