std.algorithm.remove and principle of least astonishment

Michel Fortin michel.fortin at michelf.com
Mon Nov 22 06:37:36 PST 2010


On 2010-11-22 09:09:41 -0500, spir <denis.spir at gmail.com> said:

> On Mon, 22 Nov 2010 08:24:33 -0500
> Michel Fortin <michel.fortin at michelf.com> wrote:
> 
>> I agree there might be a use case for a special data type allowing fast
>> random access to graphemes and able to retain the precise count of
>> graphemes. But if what you do only requires iterating over all
>> graphemes, a wrapper range that converts to graphemes on the fly might
>> be less overhead than building a separate data structure.
> 
> It's true as long as you can assert each string is iterated at most once. B
> ut the job of constructing an instance of "UText" (say, grapheme string) sh
> ould be exactly the same as what each iteration has to do on the fly. Or do
>  i miss a point?

I think you missed my point.

My point was that decoding on the fly while iterating might be as fast 
or maybe faster in most cases (which don't include grapheme clusters) 
than if you had already predecoded the graphemes and stored them in a 
grapheme-oriented data structure. I say that mostly because of the 
variable-length nature of a grapheme makes it hard to store one 
efficiently.

That's my opinion, but debating that is rather pointless in the absence 
of an implementation of each to compare.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list