From: Martyn Pike <usenet@embeddedconsultinguk.com>
Subject: Re: Question about reference types
Date: Mon, 27 Oct 2014 18:09:40 +0000
Date: 2014-10-27T18:09:40+00:00 [thread overview]
Message-ID: <544e8a6b$0$1473$c00b7f07@94.232.116.90> (raw)
In-Reply-To: <aa04bd67-d170-48e3-a659-239fb8acd0a9@googlegroups.com>
On 27/10/2014 12:09, rkodinets@gmail.com wrote:
> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
>
> procedure Ada_Test is
>
> type Obj is record
> A : aliased Integer;
> end record;
>
> type Obj_Access is access Obj;
>
> type Accessor (Data : access constant Integer) is null record with
This is where the error is. Data is constant.
> Implicit_Dereference => Data;
>
> function Get_Int (This : Obj_Access) return Accessor is
> begin
> return Accessor'(Data => This.A'Access);
> end Get_Int;
>
> X : Obj_Access := new Obj'(A => 22);
> begin
> Get_Int(X).Data.all := 33; -- Error: left hand side of assignment must be a variable
> Get_Int(X) := 33; -- No error.
> Put(X.A); -- This gives 33.
> New_Line;
> end Ada_Test;
next prev parent reply other threads:[~2014-10-27 18:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 12:09 Question about reference types rkodinets
2014-10-27 12:31 ` G.B.
2014-10-27 12:37 ` rkodinets
2014-10-27 22:39 ` Randy Brukardt
2014-10-28 12:33 ` Martyn Pike
2014-10-28 13:05 ` Roman Kodinets
2014-10-28 19:50 ` Martyn Pike
2014-10-28 22:53 ` Roman Kodinets
2014-10-27 18:09 ` Martyn Pike [this message]
2014-10-28 13:41 ` Roman Kodinets
2014-10-28 17:45 ` Roman Kodinets
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox