comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Ann: Natools.Chunked_Strings, beta 1
Date: Wed, 30 Nov 2011 09:51:01 +0000 (UTC)
Date: 2011-11-30T09:51:01+00:00	[thread overview]
Message-ID: <slrnjdbv3n.1lme.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 4ed5119e$0$7619$9b4e6d93@newsspool1.arcor-online.net

On 2011-11-29, Georg Bauhaus <rm.dash-bauhaus@futureapps.de> wrote:
> The package GNAT.Spitbol.Patterns uses Unbounded_String extensively.
> Last time I checked it seemed possible to replace the dependence
> on Ada.Strings.Unbounded with one on a compatible package.
> The very first definition in GNAT.Spitbol is
>
>    subtype VString is Ada.Strings.Unbounded.Unbounded_String;
>
> It should be sufficient to change this definition and
>
>    Nul : VString renames Ada.Strings.Unbounded.Null_Unbounded_String;
>
> to use your strings, in local copies of the sources of the
> GNAT.Spitbol hierarchy.

Also To_Unbounded_String has to be replaced by To_Chunked_String, but
this is also conveniently renamed at the same place.

> Of particular interest might be, I think, anything that can improve
> replacement in objects of type Unbounded_String.

It seems we are talking about the transformation of
Prefix & Old & Suffix into Prefix & Replacement & Suffix, with
Old'Length /= Replacement'Length. In that case, Chunked_String is
probably not an improvement over Unbounded_String, since in both cases
the whole Suffix has to be moved, so they should be of similar speed
with a slight advantage for Unbounded_String because the contiguous
memory is more cache-friendly.

However it seems to be the kind of use-cases for which ropes were
designed. So it leads to the question, is there already an Ada
implementation of ropes somewhere?

Assuming there isn't, I wouldn't mind starting one. It seems to be an
interesting toy problem.

When thinking about it, the first tricky part I identified is dealing
with reference-counted object in a thread-safe way (the original paper
assumed a garbage collector). It will probably involve writing tree
algorithms from scratch (to efficiently preserve the rope invariant when
rebalancing or rotating), so I will end up with accesses to reference
counted nodes. I guess using a protected type for nodes will take care
of the thread safety, but I will need to somehow indicate whether I'm
dereferencing the access for reading or for read/write. I might be an
interesting concurrency exercise, but I don't really know how to
properly test it.



Thanks for your interest,
Natasha



  reply	other threads:[~2011-11-30  9:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29 15:16 Ann: Natools.Chunked_Strings, beta 1 Natasha Kerensikova
2011-11-29 15:37 ` Pascal Obry
2011-11-29 16:34   ` Natasha Kerensikova
2011-11-29 17:08     ` Georg Bauhaus
2011-11-30  9:51       ` Natasha Kerensikova [this message]
2011-11-29 20:25     ` Randy Brukardt
2011-11-30 10:44     ` Yannick Duchêne (Hibou57)
2011-11-30 10:39   ` Yannick Duchêne (Hibou57)
2011-11-30 10:57     ` Dmitry A. Kazakov
2011-12-01  0:11       ` Randy Brukardt
2011-12-01  8:30         ` Dmitry A. Kazakov
2011-12-01 23:26           ` Vinzent Hoefler
2011-12-02  8:27             ` Dmitry A. Kazakov
2011-12-02  9:30               ` Georg Bauhaus
2011-12-02 13:11                 ` Dmitry A. Kazakov
2011-12-02  0:39           ` Randy Brukardt
2011-12-01  9:02         ` Yannick Duchêne (Hibou57)
2011-11-30 13:08     ` Natasha Kerensikova
2011-11-30 19:39       ` Jeffrey Carter
2011-12-01 10:57         ` Natasha Kerensikova
2011-12-01 19:07           ` Jeffrey Carter
2011-12-01 21:19             ` Yannick Duchêne (Hibou57)
2011-12-01 22:49               ` Natasha Kerensikova
2011-12-02 16:16         ` Tero Koskinen
2011-12-02 17:36           ` Adam Beneschan
2011-12-02 18:52             ` Tero Koskinen
2011-12-02 18:14           ` Yannick Duchêne (Hibou57)
2011-12-02 19:07             ` Adam Beneschan
2011-11-30 10:33 ` Yannick Duchêne (Hibou57)
2011-11-30 11:04   ` Natasha Kerensikova
replies disabled

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