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 > Limited returns
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 17 Topic 5772 of 5881
Post > Topic >>

Limited returns

by "Dmitry A. Kazakov" <mailbox@[EMAIL PROTECTED] > Jun 23, 2008 at 04:21 PM

Let's consider this:

   with Ada.Finalization;
   procedure Test_Limited_Stuff is
      type I is limited interface;

      type T is new Ada.Finalization.Limited_Controlled with record
         A : Integer;
      end record;

      type S is new T and I with record
         Self : not null access S'Class := S'Unchecked_Access;
      end record;

      function Factory return I'Class is
      begin
         return X : S;
-- GNAT: wrong type for return_subtype_indication
      end Factory;
   begin
      null;
   end Test_Limited_Stuff;

Is it illegal? I am surprised why? S is in I'Class.

OK, if that is indeed illegal, then let's make another try:

      function Factory return I'Class is
      begin
         return X : I'Class := S'(T with others => <>);
-- GNAT: expected an access type with designated type "S'Class" defined
...
-- found an access type with designated type "I'Class" defined ...
      end Factory;

....still illegal, but more interesting. It seems that a Rosen's trick
member cannot be initialized because the object's type is more general
than
the designated access type. It should not be so. A compiler bug?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
 




 17 Posts in Topic:
Limited returns
"Dmitry A. Kazakov&q  2008-06-23 16:21:07 
Re: Limited returns
fedya_fedyakoff@[EMAIL PR  2008-06-23 08:04:33 
Re: Limited returns
fedya_fedyakoff@[EMAIL PR  2008-06-23 08:20:51 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-23 18:53:57 
Re: Limited returns
Adam Beneschan <adam@[  2008-06-23 08:49:01 
Re: Limited returns
fedya_fedyakoff@[EMAIL PR  2008-06-24 03:13:04 
Re: Limited returns
fedya_fedyakoff@[EMAIL PR  2008-06-24 03:56:19 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-24 15:51:30 
Re: Limited returns
fedya_fedyakoff@[EMAIL PR  2008-06-24 08:01:01 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-24 18:31:12 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-24 18:42:42 
Re: Limited returns
Adam Beneschan <adam@[  2008-06-23 08:15:12 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-23 19:03:24 
Re: Limited returns
Adam Beneschan <adam@[  2008-06-23 11:15:23 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-23 21:44:33 
Re: Limited returns
=?ISO-8859-1?Q?Egil_H=F8v  2008-06-26 05:35:34 
Re: Limited returns
"Dmitry A. Kazakov&q  2008-06-26 16:12:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sat Sep 6 15:38:38 CDT 2008.