Re: pseudo-specs for a String class

From: Kinkie <gkinkie_at_gmail.com>
Date: Wed, 27 Aug 2008 22:42:30 +0200

On Wed, Aug 27, 2008 at 8:04 PM, Henrik Nordstrom
<henrik_at_henriknordstrom.net> wrote:
> ons 2008-08-27 klockan 11:10 +0200 skrev Kinkie:
>
>> I'm unconvinced. What's the purpose of a MemoryRegion if you can't
>> manipulate it?
>
> You can manipulate it, but at a rather low level. You can also append to
> it by adding a MemoryRegion (or String), you can access raw octets. But
> you can't do any fancier string family operations such as tokenising
> based on separators, case-insensitive compare, substring search, etc...
>
> a MemoryRegion is binary data.
>
> a String is character data.
>
>> In C, it makes sense to provide different API: strings provide
>> different semantics than char* (they're null-terminated).
>>
>> But here?
>> Everything is bounds-safe or it's not worth the effort.
>> NULL-termination is optional and only used when exporting the
>> underlying data..
>
> Strings have character properties. MemoryRegions not.

Er.. Except for documenting what each object is supposed to contain, I
don't see much functional difference between
MemRegion->memchr(char)
and String->strchr(char)

Let's also see things from the side of users: in most cases I expect
we'll want to perform string manipulation (and thus need to typecast)
on at least part of a MemRegion.
It's not a problem tho.. I'll prototype the feature-rich user-facing
class, then we split the interface in two and define what belongs to
MemRegion and what belongs to a String (which we'll need to subclass
to provide character-set-oriented semantics, but that's out of scope
here).

-- 
 /kinkie
Received on Wed Aug 27 2008 - 20:42:39 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 28 2008 - 12:00:08 MDT