Re: pseudo-specs for a String class

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 27 Aug 2008 11:15:43 -0600

On Wed, 2008-08-27 at 17:27 +0800, Adrian Chadd wrote:
> 2008/8/27 Kinkie <gkinkie_at_gmail.com>:
>
> >> * Memory: some chunk of contiguous memory somewhere;
> >> * MemoryRegion: some reference to { Memory, offset, length }
> >> * String: a MemoryRegion and some routines to manipulate it
> >
> > I'm unconvinced. What's the purpose of a MemoryRegion if you can't
> > manipulate it? ... if it behaves like a string, it is a
> > string, despite the fact that it might actually be a buffer, or a
> > blob.
>
> I had a long ranty email with lots of points, but I'll summarise and
> save y'all the trouble.
>
> A memory region can be manipulated (passed into vector IO, modified
> with COW or not semantics, etc). Its just an array of bytes.
>
> A string includes things like potentially caring about character
> encoding in things like length calculations, comparisons, etc. A
> memory region doesn't. A string is generally a representation of
> printable data; a memory region isn't.
>
> A string gets the benefits of a memory region (reference counting,
> vectorised IO, etc) and just adds functionality on top of it.

Adrian is right. The conceptual difference between an Opaque Memory
Region and a Meaningful Char String is significant. Codifying that
difference may have no runtime effect, but it does improve the overall
code quality.

I am not saying you MUST implement all the three layers discussed here,
but doing so would increase the value of your contribution, IMO.

HTH,

Alex.
Received on Wed Aug 27 2008 - 17:16:38 MDT

This archive was generated by hypermail 2.2.0 : Wed Aug 27 2008 - 12:00:06 MDT