Re: pseudo-specs for a String class

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Wed, 27 Aug 2008 23:58:25 +1200

Kinkie wrote:
>> I had a long ranty email with lots of points, but I'll summarise and
>> save y'all the trouble.
>
> Thanks, I appreciate that.
>
>> 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.
>>
>> Would you use a "String" as the reference counted type for say, the
>> memory store?
>
> NOW I get the point :)
> To me a String is just an abstraction of a refcounted char*: it
> doesn't care about encodings etc.
> This is the cause of the whole misunderstanding: my implementation of
> a String is not a string at all, but more like a string-friendly blob,
> suited for low-level stuff such as for instance the memory store.
>
> Any suggestions for how should I rename the class? Would MemBlob sound
> good to everyone (let's keep it short, please)..
>

No. MemBuf would be good, but thats already used. If the assumptions
Squid makes of MemBuf allow it to be replaced entirely by your buffer
object. Great re-use the name too.

I disagree with Adrian on this one, a String is whatever we define a
String to be. Printable characters or not. After all, an ascii string
can have whitespace and NULL, and unicode text is 100% binary encrypted
blobs at the byte level.
  As long as its contents are known to be contiguous in meaning and
information content it fits the description of String to me. Also, we
are mostly using them to represent pieces of HTTP Headers, which is a
protocol built of classical Strings.

If you are implementing the BetterStringBuffer (next generation)
objects, I'd go with RefString or similar. Since its ref-counted.

If you want to be pedantic about the printable char issue, DataBuffer
makes more descriptive sense.

Amos

-- 
Please use Squid 2.7.STABLE4 or 3.0.STABLE8
Received on Wed Aug 27 2008 - 11:58:27 MDT

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