comp.lang.ada
 help / color / mirror / Atom feed
From: Gene <gene.ressler@gmail.com>
Subject: Re: Using Ada.Containers.Vector and Limited Private types
Date: Fri, 11 Jul 2008 19:45:47 -0700 (PDT)
Date: 2008-07-11T19:45:47-07:00	[thread overview]
Message-ID: <940db060-ef08-4e1c-9556-0514181183eb@j22g2000hsf.googlegroups.com> (raw)
In-Reply-To: 6QQdk.194211$TT4.37376@attbi_s22

On Jul 11, 6:06 pm, "Jeffrey R. Carter"
<spam.jrcarter....@spam.acm.org> wrote:
> Gene wrote:
>
> > But as Dmitry pointed out, what I wrote has some portability risk.  To
> > avoid this, just copy the bits you need into your own (non-limited)
> > data structure.
>
> > with Ada.Text_IO;            use Ada.Text_IO;
> > with Ada.Integer_Text_IO;    use Ada.Integer_Text_IO;
> > with Ada.Containers.Vectors;
> > with Ada.Directories;        use Ada.Directories;
> > with Ada.Calendar;           use Ada.Calendar; -- for comparing  date/
> > times
>
> > procedure List_By_Date is
>
> >    type String_Ptr_Type is access String;
> >    type File_Info_Type is
> >       record
> >          Modification_Time : Time;
> >          Simple_Name : String_Ptr_Type; -- Freed with storage pool!
>
> I would recommend using Ada.Strings.Unbounded.Unbounded_String with its
> automatic and tested memory management over implementing new and untested memory
> allocation and management yourself.
>
> --
> Jeff Carter
> "Well, a gala day is enough for me. I don't think
> I can handle any more."
> Duck Soup
> 93- Hide quoted text -
>
> - Show quoted text -

Right.  I initially did it with UBS and changed it. Unbounded_String,
at least in the GNAT implementation, is a super heavyweight.  In this
case, you call Simple_Name to get a string and then convert it to an
unbounded string.  In Ada 95 you'd have to convert back to a simple
String for printing; fortunately that's fixed in 2005.  Nonetheless
the syntax and the compiled code are both unsatisfying.  Barnes seems
to agree:

... conversion between bounded and unbounded strings and the raw type
String is required rather a lot and is both ugly and inefficient.

I do not find that relying on a simple new' and storage pool for
release to be a very intimidating form of memory management.



  reply	other threads:[~2008-07-12  2:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-05 11:53 Using Ada.Containers.Vector and Limited Private types Dale Stanbrough
2008-07-05 15:42 ` george.priv
2008-07-06 18:09 ` Gene
2008-07-06 19:18   ` Dmitry A. Kazakov
2008-07-07 13:29     ` Gene
2008-07-07 14:15       ` Dmitry A. Kazakov
2008-07-07 18:39         ` Gene
2008-07-10  0:16   ` Dale Stanbrough
2008-07-10  7:31     ` Dmitry A. Kazakov
2008-07-10 22:59     ` Gene
2008-07-11 22:06       ` Jeffrey R. Carter
2008-07-12  2:45         ` Gene [this message]
2008-07-12  4:41           ` Jeffrey R. Carter
2008-07-13 15:30             ` Gene
2008-07-13 18:10               ` Jeffrey R. Carter
2008-07-16 21:23               ` Simon Wright
2008-07-12  8:02           ` Dmitry A. Kazakov
2008-07-12  7:53       ` Dmitry A. Kazakov
replies disabled

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