TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To: Craig Carey <[log in to unmask]>
Date: Mon, 29 Oct 2001 11:13:10 -0800
Reply-To: Vincent Celier <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii; format=flowed
From: Vincent Celier <[log in to unmask]>
Parts/Attachments: text/plain (41 lines)
I don't think that your example is adequate for the new feature you
advocate.

   X.Ptr.all := Y.Ptr.all;

is a very dangerous statement, because X.Ptr may point to a too short
string.

Your example is about unbounded strings that are manually finalized.

I would write them as:

package SV is

   type Vstr is limited private;

   procedure Assign (To : in out Vstr; From : Vstr);

   function Image (Source : Vstr) return String;

   --  ...

private

   type String access is access all String;
   Null_String_Access   : constant String_Access := new String'("");

   type Vstr is record
      Ptr : String_Access := Null_String_Access;
      Len : Natural := 0;
   end record;

end SV;

Unbounded_Strings are relatively slow in Ada, because they must be
implemented as controlled objects.

If the spec above is not adequate for your example, please tell us.

--  Vincent Celier

ATOM RSS1 RSS2