comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Extending discriminant types
Date: Thu, 20 Nov 2008 22:59:57 GMT
Date: 2008-11-20T22:59:57+00:00	[thread overview]
Message-ID: <NZlVk.36083$_Y1.11594@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 26f0cb8c-eb3e-4c0d-85d1-f45e2c1ba4c6@j38g2000yqa.googlegroups.com

First, the second specification package that I use was written by 
"Pascal Leroy". another editor of the Ada 2005 RM. "Randy Brukardt" 
skip this topic.

QUOTE
Our compiler currently rejects the following code fragment because it 
complains that the overriding "=" is not subtype conformant with the 
inherited "=" (3.9.2(10)):

       package P is
                type T is tagged private;
                function "=" (Left, Right : T'Base) return Boolean;
        private
                type T is tagged null record;
        end P;


T is a constrained subtype as per 3.2(9), so as far as I understand, T is
different from the "T italic" used in 4.5.2(7).

I hope that there is flaw in my reasoning, because if it is correct, it 
looks like we have a pretty severe problem...

Pascal
UNQUOTE


And since both RM 95 and RM 2005, do not clarify that the "Base" attribute  
is for scalar types only, then you must assume that the "Base' attribute 
can apply to other types as well. Else either "Pascal Leroy" or may be 
"Randy Brukardt" would have correct the misunderstanding of this 
attribute, especially since, Pascal implied the understanding in the 
first place by use of his example.


Now to the RM.

From the RM 95, Annex N:

38   Subtype.  A subtype is a type together with a constraint, which
constrains the values of the subtype to satisfy a certain condition.  The
values of a subtype are a subset of the values of its type.

With that in mind. The definition of the "Base attribute" in Annex K: 

18   S'Base denotes an unconstrained subtype of the type of S. This 
     unconstrained subtype is called the base subtype of the type.
     See 3.5.

and from RM 3.5

S'Base:  denotes an unconstrained subtype of the type of S. This 
         unconstrained subtype is called the base subtype of
         the type.

Also Annex K says "For every scalar subtype S:" it does not say for 
"For every scalar subtypes S only:". 

And even though GNAT stops the programmers ability to create new 
attributes, it does not stop the programmer from using those that have 
been predefined for a more general meaning.

So, as long as you define the the "Base attribute" as an unconstrained 
subtype of a type. You have compiled with the RM and should be allowed 
in GNAT. So, the RM does not force the "Base" attribute to be for 
Scalar only and neither should GNAT.  

Plus, since that example is from Ada-auth.org one of the governing 
body of Ada, with the second being the Ada RM that is stored at 
IEEE. I choose to say that the Ada-auth.org is more likely to be 
correct on these matters.


Also, since both Duff and Beneschan weigh in on this one back then:
I kind of like what Robert said! Especially since it came from 
his Adacore email account!

As "Robert A Duff" stated to Adam Beneschan back in 2002.

QUOTE
Robert's Rule, which says that no matter what the RM says, it "really" 
says what we mean! 
UNQUOTE

I know he was trying to be funny or was he. One problem though, that 
saying works both ways!



Now, what makes you think that using GNAT 2008 with "-gnat95" would 
fix the problem. It the error is not govern by "-gnatxx" switch in GNAT 
then the error will show up regardless of what specification used.

For your information I used "GNAT 3.15p" first, then tried "GNAT GPL 2007", 
and "GNAT GPL 2008" and last night pulled out my CD of old GNAT compilers, 
and used two DOD certified compilers. And the only compilers that create 
this error are those that contain the Ada 2005 specifications, 
"GNAT GPL 2007", and "GNAT GPL 2008". So, the cause of this error is in 
the Ada 2005 specifications or changes to the compiler for the new specs. 

The true correction will occur after IBM releases their version of Ada 
2005. And we are able to compare GNAT 2008/9 to IBM's Ada. Of course, 
if someone has the IBM Ada 95 version then we could compare, the results.

Note: Back in april IBM stated, it would release the Ada 2005 compiler by 
the end of year. But, that was before the big meltdown, so we might have 
to add another year or two.


In <26f0cb8c-eb3e-4c0d-85d1-f45e2c1ba4c6@j38g2000yqa.googlegroups.com>, christoph.grein@eurocopter.com writes:
>On 20 Nov., 08:21, a...@anon.org (anon) wrote:
>> Since, the orginal post suggest that the poster was using GNAT Ada 95
>> compiler. Because the poster states that he can compiler the code. So,
>> I used Gnat 3.15p using Ada 95 specs.
>>
>> Plus, the RM does not limited the "Base" attribute to only Scalar Types.
>> Any defined type can use the "Base" attribute.
>
>Wrong, it does. Please see the RM. You can take the 95 version, the 95
>consolidated version, or the 2005 version. They all show you that
>'Base is valid for scalar types only.
>
>In my last post, I gave you chapter and verse, I repeat it here: K
>(17).
>This refers back to 3.5 Scalar Types, especially 3.5(15).
>
>Form the kind of reference, you can deduce that there has been no
>change since the very first publication of Ada 95. [Reference is in
>the form C.V(p), where p is the paragraph number, here 15. It is
>adorned with /1, if this paragraph was changed in the consolidated
>version; with /2, if it was changed in the 2005 version.] So here you
>see no change.
>
>> Then you also have RM 2005 3.8.1 (17).
>
>This is irrelevant in this context.
>
>> --
>> -- This specification was found on Ada-auth.org web site.
>> --
>> package U is
>> =A0 type T is tagged private ;
>>
>> =A0 function "=3D" ( Left, Right : T'Base ) return Boolean ;
>>
>> private
>> =A0 type T is tagged null record ;
>> end U ;
>
>Hm, then this should never have compiled - GNAT is in error here (I
>guess there are mistakes in every compiler on the world).
>
>> the previous code is valid in Ada 95 but will not compile using GNAT
>> Ada 2005 (2007 or 2008 versions).
>
>OK, AdaCore have corrected the bug.
>
>> And since a few here, like the "wiki" web sites:
>>
>> From: =A0 =A0 =A0 =A0http://en.wikibooks.org/wiki/Ada_Programming/Types
>
>Please note that wiki has no normative force. You always have to be
>suspicious about the contents. You have a good example here. The
>chapter is partly wrong!
>
>Now it was me who wrote lots of the stuff you quote here, so I'm the
>culprit. I wrote the chapter with scalar types in mind - and in fact,
>all this is true only for scalar types, not for composite types.




  parent reply	other threads:[~2008-11-20 22:59 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-15  9:16 Extending discriminant types Stefan Bellon
2008-11-15 18:50 ` Jeffrey R. Carter
2008-11-17 16:30 ` Adam Beneschan
2008-11-18 11:02   ` christoph.grein
2008-11-18 23:24     ` Adam Beneschan
2008-11-19  9:49 ` anon
2008-11-19 10:15   ` christoph.grein
2008-11-19 19:19     ` Georg Bauhaus
2008-11-19 11:38   ` Martin
2008-11-20  7:21   ` anon
2008-11-20  8:30     ` christoph.grein
2008-11-20  8:36       ` Ludovic Brenta
2008-11-20 11:45         ` Georg Bauhaus
2008-11-20 11:46           ` Georg Bauhaus
2008-11-20 23:01             ` anon
2008-11-21 11:54               ` Ludovic Brenta
2008-11-20 14:03           ` Dmitry A. Kazakov
2008-11-20 15:03           ` Robert A Duff
2008-11-20 15:57             ` Stefan Bellon
2008-11-21  0:32               ` Adam Beneschan
2008-11-20 16:11           ` Adam Beneschan
2008-11-20 22:59       ` anon [this message]
2008-11-21  0:29         ` Adam Beneschan
2008-11-21  7:25           ` anon
2008-11-21  9:19             ` Jean-Pierre Rosen
2008-11-21 10:11             ` christoph.grein
2008-11-21 12:00             ` Ludovic Brenta
2008-11-21 22:31               ` anon
2008-11-22  0:18                 ` Stefan Bellon
2008-11-23  4:06                   ` anon
2008-11-23  5:39                     ` Georg Bauhaus
2008-11-23  8:00                       ` anon
2008-11-24 10:08                         ` Georg Bauhaus
2008-11-24 22:16                           ` anon
2008-11-25 10:37                             ` Martin
2008-11-25 11:24                               ` Georg Bauhaus
2008-11-25 20:49                                 ` Jeffrey R. Carter
2008-11-25 21:01                                   ` Adam Beneschan
2008-11-25 22:09                                     ` Georg Bauhaus
2008-11-25 22:33                                       ` Jeffrey R. Carter
2008-11-26  0:58                                         ` Adam Beneschan
2008-11-26  1:45                                           ` Jeffrey R. Carter
2008-11-26  9:31                                             ` Martin
2008-11-26  9:38                                               ` Stefan Bellon
2008-11-26  9:48                                                 ` Martin
2008-11-26 10:16                                                   ` Stefan Bellon
2008-11-26 11:05                                                     ` Ludovic Brenta
2008-11-26 11:33                                                       ` Stefan Bellon
2008-11-26 15:49                                                       ` Adam Beneschan
2008-11-26 16:15                                                         ` Ludovic Brenta
2008-11-26 11:10                                                 ` Niklas Holsti
2008-11-23  8:48                     ` Compiler quality (was: Extending discriminant types) Ludovic Brenta
2008-11-24 23:33                       ` anon
2008-11-25  6:54                         ` christoph.grein
2008-11-25 10:01                         ` Ludovic Brenta
2008-11-26 23:34                           ` anon
2008-11-27 10:24                             ` Compiler quality Georg Bauhaus
2008-11-27 14:46                               ` Ludovic Brenta
2008-11-28  9:13                                 ` Martin
2008-11-28 10:28                                   ` Georg Bauhaus
2008-12-02  3:51                                     ` Randy Brukardt
2008-11-22 13:10                 ` Extending discriminant types Gautier
2008-11-24  8:24                 ` christoph.grein
2008-11-21  6:11         ` christoph.grein
2008-11-21 21:12           ` Jeffrey R. Carter
2008-11-22 16:41             ` sjw
2008-11-21 11:44         ` Martin
2008-11-20  9:55     ` Martin
replies disabled

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