On Wed, 2008-08-27 at 17:27 +0800, Adrian Chadd wrote: > 2008/8/27 Kinkie <[EMAIL PROTECTED]>: > > >> * 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.