TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Proportional Font
Show HTML Part by Default
Show All Mail Headers

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

Print Reply
Vincent Celier <[log in to unmask]>
Mon, 29 Oct 2001 11:13:10 -0800
text/plain (41 lines)
I don't think that your example is adequate for the new feature you

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

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

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;

   --  ...


   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