comp.lang.ada
 help / color / mirror / Atom feed
* Definition of "aliased"
@ 1998-10-26  0:00 Matthew Heaney
  1998-10-26  0:00 ` Tucker Taft
  1998-10-26  0:00 ` dennison
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Heaney @ 1998-10-26  0:00 UTC (permalink / raw)


What is the definition of "aliased"?  I thought
--per RM95 3.10 (9)-- that the "current instance" of a limited type was
defined to be aliased.

Yet when I try to compile this code fragment...

package P is
   type T is tagged limited private;
private
   function Op (O : access T) return Integer;
   type T is
      tagged limited record
         I : Integer := Op (T'Access);
      end record;
end P;


with P;
procedure Test_P is
   O : P.T;
begin
   null;
end;

...my compiler is telling me that

(start of message)
$ gnatmake test_p
gcc -c test_p.adb
p.ads:7:29: prefix of "Access" attribute must be aliased
gnatmake: "test_p.adb" compilation error
(end of message)

The behavior of function Op appears to be no different from Initialize
for a Controlled type.  What's the difference?

I was trying to do some non-trivial default initialization for objects
of the type, without deriving from Controlled and overriding
Initialize.  The latter approach seems like too heavy a solution.

Thanks,
Matt








^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Definition of "aliased"
  1998-10-26  0:00 Definition of "aliased" Matthew Heaney
  1998-10-26  0:00 ` Tucker Taft
@ 1998-10-26  0:00 ` dennison
  1998-10-26  0:00   ` Matthew Heaney
  1 sibling, 1 reply; 6+ messages in thread
From: dennison @ 1998-10-26  0:00 UTC (permalink / raw)


In article <m37lxo6pii.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:

> package P is
>    type T is tagged limited private;
> private
>    function Op (O : access T) return Integer;
>    type T is
>       tagged limited record
>          I : Integer := Op (T'Access);
Hmmm. Doesn't this -----------^ have to be an object or
subprogram? It appears to be a type.

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Definition of "aliased"
  1998-10-26  0:00 Definition of "aliased" Matthew Heaney
@ 1998-10-26  0:00 ` Tucker Taft
  1998-10-26  0:00 ` dennison
  1 sibling, 0 replies; 6+ messages in thread
From: Tucker Taft @ 1998-10-26  0:00 UTC (permalink / raw)


Matthew Heaney (matthew_heaney@acm.org) wrote:

: What is the definition of "aliased"?  I thought
: --per RM95 3.10 (9)-- that the "current instance" of a limited type was
: defined to be aliased.

: Yet when I try to compile this code fragment...

You seem to have run into a compiler bug.  Our Ada 95
front end has no problem with the following code.

: package P is
:    type T is tagged limited private;
: private
:    function Op (O : access T) return Integer;
:    type T is
:       tagged limited record
:          I : Integer := Op (T'Access);
:       end record;
: end P;


: with P;
: procedure Test_P is
:    O : P.T;
: begin
:    null;
: end;

: ...my compiler is telling me that

: (start of message)
: $ gnatmake test_p
: gcc -c test_p.adb
: p.ads:7:29: prefix of "Access" attribute must be aliased
: gnatmake: "test_p.adb" compilation error
: (end of message)

: The behavior of function Op appears to be no different from Initialize
: for a Controlled type.  What's the difference?

: I was trying to do some non-trivial default initialization for objects
: of the type, without deriving from Controlled and overriding
: Initialize.  The latter approach seems like too heavy a solution.

Perhaps it is time to file a bug report... (or experiment with
additional compilers ;-).

: Thanks,
: Matt

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Definition of "aliased"
  1998-10-26  0:00 ` dennison
@ 1998-10-26  0:00   ` Matthew Heaney
  1998-10-27  0:00     ` dennison
  0 siblings, 1 reply; 6+ messages in thread
From: Matthew Heaney @ 1998-10-26  0:00 UTC (permalink / raw)


dennison@telepath.com writes:

> In article <m37lxo6pii.fsf@mheaney.ni.net>,
>   Matthew Heaney <matthew_heaney@acm.org> wrote:
> 
> > package P is
> >    type T is tagged limited private;
> > private
> >    function Op (O : access T) return Integer;
> >    type T is
> >       tagged limited record
> >          I : Integer := Op (T'Access);
> Hmmm. Doesn't this -----------^ have to be an object or
> subprogram? It appears to be a type.

It _is_ an object.  Used this way, T'Access denotes the "current
instance."






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Definition of "aliased"
  1998-10-26  0:00   ` Matthew Heaney
@ 1998-10-27  0:00     ` dennison
  1998-10-28  0:00       ` Robert I. Eachus
  0 siblings, 1 reply; 6+ messages in thread
From: dennison @ 1998-10-27  0:00 UTC (permalink / raw)


In article <m3zpaj621f.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:
> dennison@telepath.com writes:
>
> > In article <m37lxo6pii.fsf@mheaney.ni.net>,
> >   Matthew Heaney <matthew_heaney@acm.org> wrote:
> >
> > > package P is
> > >    type T is tagged limited private;
> > > private
> > >    function Op (O : access T) return Integer;
> > >    type T is
> > >       tagged limited record
> > >          I : Integer := Op (T'Access);
> > Hmmm. Doesn't this -----------^ have to be an object or
> > subprogram? It appears to be a type.
>
> It _is_ an object.  Used this way, T'Access denotes the "current
> instance."
>
>

Cool! I don't suppose that trick works for tasks as well? Being able to
display Task_Type'Storage_Size would sure be handy inside of a Storage_Error
exception handler...

--
T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Definition of "aliased"
  1998-10-27  0:00     ` dennison
@ 1998-10-28  0:00       ` Robert I. Eachus
  0 siblings, 0 replies; 6+ messages in thread
From: Robert I. Eachus @ 1998-10-28  0:00 UTC (permalink / raw)


In article <714ll9$ft8$1@nnrp1.dejanews.com> dennison@telepath.com writes:

 > Cool! I don't suppose that trick works for tasks as well? Being able to
 > display Task_Type'Storage_Size would sure be handy inside of a Storage_Error
 > exception handler...

   Should work fine, inside a task the name denotes the current
instance, see RM 8.6(17) and RM 9.1(19).  If you need to name a type
itself inside its definition you have to create a subtype outside.
(Note: Running a program containing the following task type may be
hazardous to your computer's health.)

    task type Rabbit is end Rabbit;
    subtype Bunny is Rabbit;
    task body Rabbit is
      Child1, Child2: Bunny;
    begin delay 1.0; end Rabbit;

    Don't let this example convince you that you never want to use this
feature.  A much saner use is to create a backup task that doesn't
start running (and create its own backup) until the task that created
it dies.

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-10-28  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-26  0:00 Definition of "aliased" Matthew Heaney
1998-10-26  0:00 ` Tucker Taft
1998-10-26  0:00 ` dennison
1998-10-26  0:00   ` Matthew Heaney
1998-10-27  0:00     ` dennison
1998-10-28  0:00       ` Robert I. Eachus

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