comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: We should introduce aliased types
Date: Fri, 1 Aug 2014 14:44:57 -0500
Date: 2014-08-01T14:44:57-05:00	[thread overview]
Message-ID: <lrgqnq$4i3$1@loke.gir.dk> (raw)
In-Reply-To: lrgnoc$di6$1@speranza.aioe.org

"Victor Porton" <porton@narod.ru> wrote in message 
news:lrgnoc$di6$1@speranza.aioe.org...
>I think we should introduce aliased types to allow self-referencing objects
> and objects which we can access for object's internal purposes:
>
> type T is aliased
>   record
>      Ptr: access all T;
>   end;
>
> Every value of an aliased type should be aliased (whether we specify that
> the particular value if aliased or don't specify).

You do know that this is already true of almost all limited types (without 
any declaration)?

I.e.

    type T;
    type Ptr_Holder (D : access T) is limited null record;
    type T is limited record
       Ptr : Ptr_Holder (T'Access);
    end record;

is legal Ada.

It's not allowed for non-limited types because assigning the object would 
break the self-referential link (it would point to the wrong object 
afterwards).

And you can't directly declare a component as
    Ptr : access T := T'Access;
because of accessibility; the problem isn't whether T is aliased or not. 
"access T" is a library-level type, while T'Access might refer to a local 
object, so the access type could outlive the object (in particular, this 
component could be copied into an object of another library-level type), and 
that's not allowed.

Your idea would have to have the same restriction, so it wouldn't help any.

                                  Randy.


  parent reply	other threads:[~2014-08-01 19:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 18:54 We should introduce aliased types Victor Porton
2014-08-01 18:56 ` Victor Porton
2014-08-01 19:16 ` Victor Porton
2014-08-01 19:47   ` Randy Brukardt
2014-08-01 19:57     ` Victor Porton
2014-08-01 19:44 ` Randy Brukardt [this message]
2014-08-01 19:49   ` Randy Brukardt
2014-08-01 20:39 ` sbelmont700
replies disabled

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