Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Discriminan...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 9 Topic 5610 of 5828
Post > Topic >>

Re: Discriminant ans tagged type ?!

by "Tom Grosman" <grosman@[EMAIL PROTECTED] > Apr 4, 2008 at 05:40 PM

"Tony" <truand.tony@[EMAIL PROTECTED]
> a écrit dans le message de news: 
cc37c7dc-d89b-4f4a-82e3-24941300efb5@[EMAIL PROTECTED]
> On 21 mar, 16:25, Adam Beneschan <a...@[EMAIL PROTECTED]
> wrote:
>> On Mar 21, 1:18 am, Tony <truand.t...@[EMAIL PROTECTED]
> wrote:
>>
>>
>>
>> > On 18 mar, 20:54, Adam Beneschan <a...@[EMAIL PROTECTED]
> wrote:
>>
>> > > On Mar 18, 8:54 am, Adam Beneschan <a...@[EMAIL PROTECTED]
> wrote:
>>
>> > > > However, I tried changing the declaration of T as follows:
>>
>> > > >    T : String (1 .. B.L);  -- NO, THIS IS WRONG, I SCREWED UP
>>
>> > > > and GNAT accepted it.  (I haven't done enough testing to make
sure
>> > > > GNAT handles it correctly in other ways, though.)  Here, B refers

>> > > > to
>> > > > the "current instance" of the type (8.6(17)), and 3.7(18) means 
>> > > > that
>> > > > all instances of the type will have a component L that is
inherited
>> > > > from A, so this should be legal unless there are some other rules

>> > > > that
>> > > > I've missed (and that GNAT also missed).
>>
>> > > Never mind.  After reading Bob's post, I got pointed to 3.8(10-12),
>> > > which disallows references to inherited discriminants in a type
>> > > extension.  So I guess GNAT (or at least the version I'm using,
which
>> > > is probably not the latest) is wrong to accept this.  Sorry.
>>
>> > >                                   -- Adam
>>
>> > --
>> > I tried Bob's answer with the Aonix compiler:
>> > ERROR : LRM:3.8(12), A discriminant used in a constraint may only
>> > appear alone as a direct_name.
>> > I'm lost...;-)
>>
>> 3.8(12) is one of the rules I overlooked (thanks, Tuck).  Perhaps you
>> tried  Bob's answer together with my incorrect suggestion to use
>> string(1..B.L), which violates that rule; when you use a discriminant
>> in a constraint, the discriminant can't be an "expanded name" or part
>> of a larger expression, and I think B.L is an expanded name here.  My
>> apologies for misleading you.
>>
>> This should work:
>>
>>     type B (L : Natural) is new A(L) with record
>>          T : String (1 .. L);
>>     end record;
>>
>> Everything I said earlier about visibility wouldn't apply here,
>> because redeclaring the discriminant L makes it visible inside the
>> record declaration of B.  This would work too:
>>
>>     type B (Ell : Natural) is new A(L) with record
>>          T : String (1 .. Ell);
>>     end record;
>>
>> It's the new discriminant that can be used in the declaration, not the
>> one inherited from A.
>>
>> > Is my first code correct? I guess yes...
>>
>> Still no.  The compiler may accept it, but that just means the
>> compiler has a bug.
>>
>> I hope I've got everything straight now.
>>
>>                                    -- Adam
> --
> You are right !!  , it works :-)
> Thanks for all.
> Tony.
> --

Tony,

Thanks for bringing this problem to our attention.

Tom Grosman, Aonix
 




 9 Posts in Topic:
Discriminant ans tagged type ?!
Tony <truand.tony@[EMA  2008-03-18 16:22:36 
Re: Discriminant ans tagged type ?!
Adam Beneschan <adam@[  2008-03-18 08:54:53 
Re: Discriminant ans tagged type ?!
Adam Beneschan <adam@[  2008-03-18 12:54:03 
Re: Discriminant ans tagged type ?!
Tony <truand.tony@[EMA  2008-03-21 01:18:58 
Re: Discriminant ans tagged type ?!
Adam Beneschan <adam@[  2008-03-21 08:25:38 
Re: Discriminant ans tagged type ?!
Simon Wright <simon.j.  2008-03-21 16:46:43 
Re: Discriminant ans tagged type ?!
Tony <truand.tony@[EMA  2008-03-22 02:05:04 
Re: Discriminant ans tagged type ?!
"Tom Grosman" &  2008-04-04 17:40:37 
Re: Discriminant ans tagged type ?!
Robert A Duff <bobduff  2008-03-18 14:40:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 14:41:30 CDT 2008.