comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Mize <smize@link.com>
Subject: Re: GNAT: Performance of String functions
Date: 1997/07/23
Date: 1997-07-23T00:00:00+00:00	[thread overview]
Message-ID: <33D66563.3F86@link.com> (raw)
In-Reply-To: 5r5cfh$irn$1@ratatosk.uio.no


Tarjei Jensen wrote:

> I'd be delighted if it is possible to write a portable bounded
> string package
> that does not copy blindly on assignment.

Here's what I understand you want:

1 Each string has its own individual maximum length, and a
  currently-used length.

2 Each string allocates ONLY its maximum length, not a max
  length for all strings of this subtype.

3 The user can assign A to B so long as the "used" length of
  A is less than the maximum length of B.

4 Normal assignment is available.

5 Unused bytes are not copied on assignment.

You can build a type to do what you want (except you have
to use a "copy" procedure), but Bounded_Type doesn't quite do
what you want.

You can get all but 4 (normal assignment) with a limited variant
record with a discriminant (max length).  To assign the value,
you provide a "copy" routine.  Don't provide a default value
for the discriminant, so the user will have to explicitly give
a max size for each variable of this type.  (If you provide a
default value, the implementation may allocate the subtype's
max size for each record.)

Since Ada's "user-defined" assignment is actually user code
adjusting and finalizing values, you can't get 4 (unused bytes
not copied) with normal assignment.  (You might get it by
using a variant record, but then the compiler can allocate
the subtype's max size for each record.)

Sam Mize




  reply	other threads:[~1997-07-23  0:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-18  0:00 GNAT: Performance of String functions Jakob Heinemann
1997-07-18  0:00 ` Robert Dewar
1997-07-19  0:00   ` Tarjei T. Jensen
1997-07-19  0:00     ` Matthew Heaney
1997-07-20  0:00     ` Robert Dewar
1997-07-20  0:00       ` Tarjei T. Jensen
1997-07-20  0:00         ` Robert Dewar
1997-07-21  0:00           ` Tucker Taft
1997-07-21  0:00             ` Robert Dewar
1997-07-21  0:00             ` Tarjei Jensen
1997-07-21  0:00               ` Matthew Heaney
1997-07-22  0:00               ` Robert Dewar
1997-07-22  0:00                 ` Tarjei Jensen
1997-07-22  0:00                   ` Larry Kilgallen
1997-07-22  0:00                     ` Tarjei T. Jensen
1997-07-23  0:00                       ` Larry Kilgallen
1997-07-23  0:00                       ` Robert Dewar
1997-07-23  0:00                         ` Tarjei Jensen
1997-07-23  0:00                           ` Samuel Mize [this message]
1997-07-23  0:00                             ` W. Wesley Groleau x4923
1997-07-24  0:00                             ` Robert A Duff
1997-07-24  0:00                           ` Mats Weber
1997-07-24  0:00                             ` Robert Dewar
1997-07-28  0:00                               ` Mats Weber
1997-07-28  0:00                                 ` Matthew Heaney
1997-07-29  0:00                                   ` Robert Dewar
1997-07-28  0:00                                 ` Robert Dewar
1997-07-28  0:00                                   ` Robert Dewar
1997-07-24  0:00                             ` Tarjei Jensen
1997-07-24  0:00                               ` Robert Dewar
1997-07-24  0:00                               ` Matthew Heaney
1997-07-24  0:00                             ` Matthew Heaney
1997-07-22  0:00                   ` Robert Dewar
1997-07-20  0:00     ` Tarjei T. Jensen
1997-07-22  0:00   ` Jakob Heinemann
1997-07-23  0:00     ` Robert Dewar
replies disabled

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