comp.lang.ada
 help / color / mirror / Atom feed
* Ada 2005,Doubly_Linked_List with Controlled parameter
@ 2016-04-05  2:03 George J
  2016-04-05  2:27 ` Jeffrey R. Carter
  0 siblings, 1 reply; 19+ messages in thread
From: George J @ 2016-04-05  2:03 UTC (permalink / raw)


Hi all! I'm using Doubly_Linked_List with Controlled param, example here:

   ----------------------------------------------------------------------
   type Info_Record is new Controlled with
      record
         Name:String_Access;
      end record;
   type Info is access all Info_Record'Class;
   overriding procedure Finalize(Self:in out Info_Record);

   package Test_Containers is new Ada.Containers.Doubly_Linked_Lists(Info_Record);
   use Test_Containers;

   Test_List:Test_Containers.List;
   ----------------------------------------------------------------------
   procedure Free_String is new Ada.Unchecked_Deallocation
(Object => String,
 Name   => String_Access);

   overriding procedure Finalize(Self:in out Info_Record) is
   begin
      if  Self.Name/=null then
            Free_String(Self.Name);
      end if;
   end Finalize;

   ----------------------------------------------------------------------
   procedure Test is
   begin
   Test_List.Append(Info_Record'(Controlled with
                                   Name => new String'("Test_Name"));
   end Test;
   ----------------------------------------------------------------------

  Problem is that after calling "Append"->at once starts Finalization proc, so appended pure line. I just use an access parameter after this "Doubly_Linked_List(Info)", and it's ok now,but i think that i'm wrong,cause Finalization doesn't start with Test_List.Clear and when exiting program. So question is "How I can finalize Doubly_Connected_List Controlled parameter correctly?Or I must not use Controlled parameter in this list?".
Thanks!

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  2:03 Ada 2005,Doubly_Linked_List with Controlled parameter George J
@ 2016-04-05  2:27 ` Jeffrey R. Carter
  2016-04-05  3:00   ` George J
  2016-04-05  3:25   ` George J
  0 siblings, 2 replies; 19+ messages in thread
From: Jeffrey R. Carter @ 2016-04-05  2:27 UTC (permalink / raw)


On 04/04/2016 07:03 PM, George J wrote:
> 
> Problem is that after calling "Append"->at once starts Finalization proc, so
> appended pure line. I just use an access parameter after this
> "Doubly_Linked_List(Info)", and it's ok now,but i think that i'm wrong,cause
> Finalization doesn't start with Test_List.Clear and when exiting program. So
> question is "How I can finalize Doubly_Connected_List Controlled parameter
> correctly?Or I must not use Controlled parameter in this list?".

Rather than trying to reinvent unbounded strings (incorrectly), use
Ada.Strings.Unbounded.Unbounded_String instead of Info_Record and all your
problems will disappear. Get rid of type Info while you're at it.

-- 
Jeff Carter
"Hold your temper. Count ten.... Now let 'er go.
You got a good aim."
Never Give a Sucker an Even Break
105


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  2:27 ` Jeffrey R. Carter
@ 2016-04-05  3:00   ` George J
  2016-04-05  4:13     ` George J
                       ` (2 more replies)
  2016-04-05  3:25   ` George J
  1 sibling, 3 replies; 19+ messages in thread
From: George J @ 2016-04-05  3:00 UTC (permalink / raw)


вторник, 5 апреля 2016 г., 5:27:49 UTC+3 пользователь Jeffrey R. Carter написал:
> On 04/04/2016 07:03 PM, George J wrote:
> > 
> > Problem is that after calling "Append"->at once starts Finalization proc, so
> > appended pure line. I just use an access parameter after this
> > "Doubly_Linked_List(Info)", and it's ok now,but i think that i'm wrong,cause
> > Finalization doesn't start with Test_List.Clear and when exiting program. So
> > question is "How I can finalize Doubly_Connected_List Controlled parameter
> > correctly?Or I must not use Controlled parameter in this list?".
> 
> Rather than trying to reinvent unbounded strings (incorrectly), use
> Ada.Strings.Unbounded.Unbounded_String instead of Info_Record and all your
> problems will disappear. Get rid of type Info while you're at it.
> 
> -- 
> Jeff Carter
> "Hold your temper. Count ten.... Now let 'er go.
> You got a good aim."
> Never Give a Sucker an Even Break
> 105

Ok,thanks,and if I correctly understood,if I have record with multiple parameters, i must do it like
---------------------------------
 type Info_Record is
    Name:Unbounded_String;--ok
    Surname:Unbounded_String;
    Age:Natural;
 end Info_Record;
--------------------------------
Am I right?
And are they normally will be deleted from memory with finalization of Doubly_Connected_List?

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  2:27 ` Jeffrey R. Carter
  2016-04-05  3:00   ` George J
@ 2016-04-05  3:25   ` George J
  2016-04-05  5:24     ` Jeffrey R. Carter
  1 sibling, 1 reply; 19+ messages in thread
From: George J @ 2016-04-05  3:25 UTC (permalink / raw)


> 
> Rather than trying to reinvent unbounded strings (incorrectly), use
> Ada.Strings.Unbounded.Unbounded_String instead of Info_Record and all your
> problems will disappear. Get rid of type Info while you're at it.
> 
> -- 
> Jeff Carter
> "Hold your temper. Count ten.... Now let 'er go.
> You got a good aim."
> Never Give a Sucker an Even Break
> 105

And i can't understand, why Finalize starts immediately after I set any data
to my record? Is it the specifics of the Finalization mechanism?

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  3:00   ` George J
@ 2016-04-05  4:13     ` George J
  2016-04-05  6:20     ` Jeffrey R. Carter
  2016-04-05  7:58     ` Dmitry A. Kazakov
  2 siblings, 0 replies; 19+ messages in thread
From: George J @ 2016-04-05  4:13 UTC (permalink / raw)


>........
> And are they normally will be deleted from memory with finalization of Doubly_Connected_List?
---

Oh, I'm Ada's noob!I didn't know that unbounded_string is controlled type!Thanks, Jeffrey! One question is opened, about specifics of the  Finalization mechaniZm..


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  3:25   ` George J
@ 2016-04-05  5:24     ` Jeffrey R. Carter
  2016-04-05  6:30       ` George J
  0 siblings, 1 reply; 19+ messages in thread
From: Jeffrey R. Carter @ 2016-04-05  5:24 UTC (permalink / raw)


On 04/04/2016 08:25 PM, George J wrote:
> 
> And i can't understand, why Finalize starts immediately after I set any data
> to my record? Is it the specifics of the Finalization mechanism?

You create an aggregate of your controlled type, which is an object of the type.
Append makes a copy of that object to store in the list. When you leave the
procedure that did the Append, the aggregate goes out of scope and is finalized.
(Presumably that leaves the copy in the list with a dangling reference.)

-- 
Jeff Carter
"Hold your temper. Count ten.... Now let 'er go.
You got a good aim."
Never Give a Sucker an Even Break
105


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  3:00   ` George J
  2016-04-05  4:13     ` George J
@ 2016-04-05  6:20     ` Jeffrey R. Carter
  2016-04-05  6:31       ` George J
  2016-04-05  7:58     ` Dmitry A. Kazakov
  2 siblings, 1 reply; 19+ messages in thread
From: Jeffrey R. Carter @ 2016-04-05  6:20 UTC (permalink / raw)


On 04/04/2016 08:00 PM, George J wrote:
 >
 > Ok,thanks,and if I correctly understood,if I have record with 
multiple parameters, i must do it like
 > ---------------------------------
 >  type Info_Record is
 >     Name:Unbounded_String;--ok
 >     Surname:Unbounded_String;
 >     Age:Natural;
 >  end Info_Record;
 > --------------------------------
 > Am I right?
 > And are they normally will be deleted from memory with finalization 
of Doubly_Connected_List?

Yes. Your example, with only a single string, appeared to be an attempt 
to reinvent Unbounded_String, but if you need a type with multiple such 
values, this is a way to do it.

"The type Unbounded_String needs finalization (see 7.6)." and "No 
storage associated with an Unbounded_String object shall be lost upon 
assignment or scope exit." ARM A.4.5

(http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-5.html).

But I see you've discovered that already.

(Some on here dislike Unbounded_String, but if it serves your purposes 
you should ignore them and use it. I worked on a large, soft-real-time 
system that used Unbounded_String extensively without problem, so such 
people's concerns seem to be unfounded.)

-- 
Jeff Carter
"Hold your temper. Count ten.... Now let 'er go.
You got a good aim."
Never Give a Sucker an Even Break
105


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  5:24     ` Jeffrey R. Carter
@ 2016-04-05  6:30       ` George J
  2016-04-06 20:29         ` Randy Brukardt
  0 siblings, 1 reply; 19+ messages in thread
From: George J @ 2016-04-05  6:30 UTC (permalink / raw)


> You create an aggregate of your controlled type, which is an object of the type.
> Append makes a copy of that object to store in the list. When you leave the
> procedure that did the Append, the aggregate goes out of scope and is finalized.
> (Presumably that leaves the copy in the list with a dangling reference.)
> 
> -- 
> Jeff Carter
> "Hold your temper. Count ten.... Now let 'er go.
> You got a good aim."
> Never Give a Sucker an Even Break
> 105

Wow,thanks,I've got! It's difficult to guess it for me.


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  6:20     ` Jeffrey R. Carter
@ 2016-04-05  6:31       ` George J
  0 siblings, 0 replies; 19+ messages in thread
From: George J @ 2016-04-05  6:31 UTC (permalink / raw)


> Yes. Your example, with only a single string, appeared to be an attempt 
> to reinvent Unbounded_String, but if you need a type with multiple such 
> values, this is a way to do it.
> 
> "The type Unbounded_String needs finalization (see 7.6)." and "No 
> storage associated with an Unbounded_String object shall be lost upon 
> assignment or scope exit." ARM A.4.5
> 
> (http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-5.html).
> 
> But I see you've discovered that already.
> 
> (Some on here dislike Unbounded_String, but if it serves your purposes 
> you should ignore them and use it. I worked on a large, soft-real-time 
> system that used Unbounded_String extensively without problem, so such 
> people's concerns seem to be unfounded.)
> 
> -- 
> Jeff Carter
> "Hold your temper. Count ten.... Now let 'er go.
> You got a good aim."
> Never Give a Sucker an Even Break
> 105

Thanks a lot, Jeffrey!

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  3:00   ` George J
  2016-04-05  4:13     ` George J
  2016-04-05  6:20     ` Jeffrey R. Carter
@ 2016-04-05  7:58     ` Dmitry A. Kazakov
  2016-04-05  8:09       ` George J
  2016-04-05  8:35       ` George J
  2 siblings, 2 replies; 19+ messages in thread
From: Dmitry A. Kazakov @ 2016-04-05  7:58 UTC (permalink / raw)


On 05/04/2016 05:00, George J wrote:

> Ok,thanks,and if I correctly understood,if I have record with
> multiple  parameters, i must do it like
> ---------------------------------
>   type Info_Record is
>      Name:Unbounded_String;--ok
>      Surname:Unbounded_String;
>      Age:Natural;
>   end Info_Record;
> --------------------------------
> Am I right?

Or, better, since you never change Name or Surname:

    type Info_Record
       (Name_Length : Positive; Surname_Length : Positive) is
    record
       Name    : String (1..Name_Length);
       Surname : String (1..Surname_Length);
       Age     : Natural;
    end Info_Record;

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

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  7:58     ` Dmitry A. Kazakov
@ 2016-04-05  8:09       ` George J
  2016-04-05  8:35       ` George J
  1 sibling, 0 replies; 19+ messages in thread
From: George J @ 2016-04-05  8:09 UTC (permalink / raw)


вторник, 5 апреля 2016 г., 10:58:29 UTC+3 пользователь Dmitry A. Kazakov написал:
> On 05/04/2016 05:00, George J wrote:
> 
> > Ok,thanks,and if I correctly understood,if I have record with
> > multiple  parameters, i must do it like
> > ---------------------------------
> >   type Info_Record is
> >      Name:Unbounded_String;--ok
> >      Surname:Unbounded_String;
> >      Age:Natural;
> >   end Info_Record;
> > --------------------------------
> > Am I right?
> 
> Or, better, since you never change Name or Surname:
> 
>     type Info_Record
>        (Name_Length : Positive; Surname_Length : Positive) is
>     record
>        Name    : String (1..Name_Length);
>        Surname : String (1..Surname_Length);
>        Age     : Natural;
>     end Info_Record;
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Wow,I didn't think, that I can do it this way!That's a trick!I'll try it now,thanks a lot, Dmitriy!

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  7:58     ` Dmitry A. Kazakov
  2016-04-05  8:09       ` George J
@ 2016-04-05  8:35       ` George J
  2016-04-05  8:50         ` Dmitry A. Kazakov
  2016-04-05 16:22         ` Jeffrey R. Carter
  1 sibling, 2 replies; 19+ messages in thread
From: George J @ 2016-04-05  8:35 UTC (permalink / raw)


...
> Or, better, since you never change Name or Surname:
> 
>     type Info_Record
>        (Name_Length : Positive; Surname_Length : Positive) is
>     record
>        Name    : String (1..Name_Length);
>        Surname : String (1..Surname_Length);
>        Age     : Natural;
>     end Info_Record;
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

I do it this way, and I have to change Doubly_Linked_List(Info_Record) to
Indefinite_DoublY_Linked(Info_Record) cause of error:"unconstrained subtype in component declaration". Am I right? Or may be it's any way to use Doubly_Linked_List? And,BTW, I'm afraid of using Indefinite List cause I think,that it can request much more memory, than Doubly_C_L,isn't it?

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  8:35       ` George J
@ 2016-04-05  8:50         ` Dmitry A. Kazakov
  2016-04-05  8:57           ` George J
  2016-04-05 16:22         ` Jeffrey R. Carter
  1 sibling, 1 reply; 19+ messages in thread
From: Dmitry A. Kazakov @ 2016-04-05  8:50 UTC (permalink / raw)


On 05/04/2016 10:35, George J wrote:
> ....
>> Or, better, since you never change Name or Surname:
>>
>>      type Info_Record
>>         (Name_Length : Positive; Surname_Length : Positive) is
>>      record
>>         Name    : String (1..Name_Length);
>>         Surname : String (1..Surname_Length);
>>         Age     : Natural;
>>      end Info_Record;
>>
>> --
>> Regards,
>> Dmitry A. Kazakov
>> http://www.dmitry-kazakov.de
>
> I do it this way, and I have to change Doubly_Linked_List(Info_Record) to
> Indefinite_DoublY_Linked(Info_Record) cause of error:"unconstrained
> subtype in component declaration". Am I right?

I am not familiar with the design of standard container's doubly-linked 
lists. Normally, a list always deals with limited indefinite elements. 
Otherwise, it does not make much sense.

> Or may be it's any way to
> use Doubly_Linked_List? And,BTW, I'm afraid of using Indefinite List
> cause I think,that it can request much more memory, than
> Doubly_C_L,isn't it?

As I said, I don't know how it is designed. There are many ways to 
design a list. One is that elements are derived from linked base 
elements. Another is that links are allocated outside and point to the 
elements. A better variant of the latter is to use a custom storage pool 
and put links before the elements. In all three methods there is no 
overhead of having elements limited indefinite.

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

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  8:50         ` Dmitry A. Kazakov
@ 2016-04-05  8:57           ` George J
  0 siblings, 0 replies; 19+ messages in thread
From: George J @ 2016-04-05  8:57 UTC (permalink / raw)


вторник, 5 апреля 2016 г., 11:50:31 UTC+3 пользователь Dmitry A. Kazakov написал:
> On 05/04/2016 10:35, George J wrote:
> > ....
> >> Or, better, since you never change Name or Surname:
> >>
> >>      type Info_Record
> >>         (Name_Length : Positive; Surname_Length : Positive) is
> >>      record
> >>         Name    : String (1..Name_Length);
> >>         Surname : String (1..Surname_Length);
> >>         Age     : Natural;
> >>      end Info_Record;
> >>
> >> --
> >> Regards,
> >> Dmitry A. Kazakov
> >> http://www.dmitry-kazakov.de
> >
> > I do it this way, and I have to change Doubly_Linked_List(Info_Record) to
> > Indefinite_DoublY_Linked(Info_Record) cause of error:"unconstrained
> > subtype in component declaration". Am I right?
> 
> I am not familiar with the design of standard container's doubly-linked 
> lists. Normally, a list always deals with limited indefinite elements. 
> Otherwise, it does not make much sense.
> 
> > Or may be it's any way to
> > use Doubly_Linked_List? And,BTW, I'm afraid of using Indefinite List
> > cause I think,that it can request much more memory, than
> > Doubly_C_L,isn't it?
> 
> As I said, I don't know how it is designed. There are many ways to 
> design a list. One is that elements are derived from linked base 
> elements. Another is that links are allocated outside and point to the 
> elements. A better variant of the latter is to use a custom storage pool 
> and put links before the elements. In all three methods there is no 
> overhead of having elements limited indefinite.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

It seems I've got.Thanks!

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  8:35       ` George J
  2016-04-05  8:50         ` Dmitry A. Kazakov
@ 2016-04-05 16:22         ` Jeffrey R. Carter
  2016-04-06  1:14           ` George J
  1 sibling, 1 reply; 19+ messages in thread
From: Jeffrey R. Carter @ 2016-04-05 16:22 UTC (permalink / raw)


On 04/05/2016 01:35 AM, George J wrote:
> ...
>>      type Info_Record
>>         (Name_Length : Positive; Surname_Length : Positive) is
>>      record
>>         Name    : String (1..Name_Length);
>>         Surname : String (1..Surname_Length);
>>         Age     : Natural;
>>      end Info_Record;
>
> I do it this way, and I have to change Doubly_Linked_List(Info_Record) to
> Indefinite_DoublY_Linked(Info_Record) cause of error:"unconstrained subtype in component declaration". Am I right? Or may be it's any way to use Doubly_Linked_List? And,BTW, I'm afraid of using Indefinite List cause I think,that it can request much more memory, than Doubly_C_L,isn't it?

Yes, you'd have to use the indefinite version for such a type, but it's nothing 
to worry about.

-- 
Jeff Carter
"Nobody expects the Spanish Inquisition!"
Monty Python's Flying Circus
22


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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05 16:22         ` Jeffrey R. Carter
@ 2016-04-06  1:14           ` George J
  0 siblings, 0 replies; 19+ messages in thread
From: George J @ 2016-04-06  1:14 UTC (permalink / raw)


вторник, 5 апреля 2016 г., 19:22:49 UTC+3 пользователь Jeffrey R. Carter написал:
> On 04/05/2016 01:35 AM, George J wrote:
> > ...
> >>      type Info_Record
> >>         (Name_Length : Positive; Surname_Length : Positive) is
> >>      record
> >>         Name    : String (1..Name_Length);
> >>         Surname : String (1..Surname_Length);
> >>         Age     : Natural;
> >>      end Info_Record;
> >
> > I do it this way, and I have to change Doubly_Linked_List(Info_Record) to
> > Indefinite_DoublY_Linked(Info_Record) cause of error:"unconstrained subtype in component declaration". Am I right? Or may be it's any way to use Doubly_Linked_List? And,BTW, I'm afraid of using Indefinite List cause I think,that it can request much more memory, than Doubly_C_L,isn't it?
> 
> Yes, you'd have to use the indefinite version for such a type, but it's nothing 
> to worry about.
> 
> -- 
> Jeff Carter
> "Nobody expects the Spanish Inquisition!"
> Monty Python's Flying Circus
> 22

Thanks,JeffreY!

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-05  6:30       ` George J
@ 2016-04-06 20:29         ` Randy Brukardt
  2016-04-06 21:04           ` Jeffrey R. Carter
  2016-04-07  1:28           ` George J
  0 siblings, 2 replies; 19+ messages in thread
From: Randy Brukardt @ 2016-04-06 20:29 UTC (permalink / raw)


"George J" <ivanov_george@list.ru> wrote in message 
news:61dd12e1-4450-4c6e-b8b5-7cf1c075ebad@googlegroups.com...
>> You create an aggregate of your controlled type, which is an object of 
>> the type.
>> Append makes a copy of that object to store in the list. When you leave 
>> the
>> procedure that did the Append, the aggregate goes out of scope and is 
>> finalized.
>> (Presumably that leaves the copy in the list with a dangling reference.)
>>
>> -- 
>> Jeff Carter
>> "Hold your temper. Count ten.... Now let 'er go.
>> You got a good aim."
>> Never Give a Sucker an Even Break
>> 105
>
> Wow,thanks,I've got! It's difficult to guess it for me.

Note that you can write something like your original code, but it has to use 
reference counts and an overriding of Adjust in order to manage the access 
value properly (since the container copies the objects, and thus you have to 
support that). I think Christoph Grein's safe pointers give an example of 
how that could be done.

In this case, the various alternatives suggested are better, since the 
compiler/runtime is doing that complicated work and you don't have to. But 
sometimes you need to manage an object this way, so it's valuable to know 
that it is possible.

                              Randy.



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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-06 20:29         ` Randy Brukardt
@ 2016-04-06 21:04           ` Jeffrey R. Carter
  2016-04-07  1:28           ` George J
  1 sibling, 0 replies; 19+ messages in thread
From: Jeffrey R. Carter @ 2016-04-06 21:04 UTC (permalink / raw)


On 04/06/2016 01:29 PM, Randy Brukardt wrote:
>
> Note that you can write something like your original code, but it has to use
> reference counts and an overriding of Adjust in order to manage the access
> value properly (since the container copies the objects, and thus you have to
> support that). I think Christoph Grein's safe pointers give an example of
> how that could be done.

Or do a deep copy.

-- 
Jeff Carter
"You can never forget too much about C++."
115

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

* Re: Ada 2005,Doubly_Linked_List with Controlled parameter
  2016-04-06 20:29         ` Randy Brukardt
  2016-04-06 21:04           ` Jeffrey R. Carter
@ 2016-04-07  1:28           ` George J
  1 sibling, 0 replies; 19+ messages in thread
From: George J @ 2016-04-07  1:28 UTC (permalink / raw)


> Note that you can write something like your original code, but it has to use 
> reference counts and an overriding of Adjust in order to manage the access 
> value properly (since the container copies the objects, and thus you have to 
> support that). I think Christoph Grein's safe pointers give an example of 
> how that could be done.
> 
> In this case, the various alternatives suggested are better, since the 
> compiler/runtime is doing that complicated work and you don't have to. But 
> sometimes you need to manage an object this way, so it's valuable to know 
> that it is possible.
> 
>                               Randy.

Thanks, Randy! I've found and added Christoph Grein's "Safe pointers" materials to bookmarks to read some later.

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

end of thread, other threads:[~2016-04-07  1:28 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05  2:03 Ada 2005,Doubly_Linked_List with Controlled parameter George J
2016-04-05  2:27 ` Jeffrey R. Carter
2016-04-05  3:00   ` George J
2016-04-05  4:13     ` George J
2016-04-05  6:20     ` Jeffrey R. Carter
2016-04-05  6:31       ` George J
2016-04-05  7:58     ` Dmitry A. Kazakov
2016-04-05  8:09       ` George J
2016-04-05  8:35       ` George J
2016-04-05  8:50         ` Dmitry A. Kazakov
2016-04-05  8:57           ` George J
2016-04-05 16:22         ` Jeffrey R. Carter
2016-04-06  1:14           ` George J
2016-04-05  3:25   ` George J
2016-04-05  5:24     ` Jeffrey R. Carter
2016-04-05  6:30       ` George J
2016-04-06 20:29         ` Randy Brukardt
2016-04-06 21:04           ` Jeffrey R. Carter
2016-04-07  1:28           ` George J

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