VLERange: a range in between BidirectionalRange and RandomAccessRange

foobar foo at bar.com
Sat Jan 15 06:09:17 PST 2011


Lutger Blijdestijn Wrote:

> Michel Fortin wrote:
> 
> > On 2011-01-15 05:03:20 -0500, Lutger Blijdestijn
> > <lutger.blijdestijn at gmail.com> said:
> ...
> >> 
> >> Is it still possible to solve this problem or are we stuck with
> >> specialized string algorithms? Would it work if VleRange of string was a
> >> bidirectional range with string slices of graphemes as the ElementType
> >> and indexing with code units? Often used string algorithms could be
> >> specialized for performance, but if not, generic algorithms would still
> >> work.
> > 
> > I have my idea.
> > 
> > I think it'd be a good idea is to improve upon Andrei's first idea --
> > which was to treat char[], wchar[], and dchar[] all as ranges of dchar
> > elements -- by changing the element type to be the same as the string.
> > For instance, iterating on a char[] would give you slices of char[],
> > each having one grapheme.
> > 
> ...
> 
> Yes, this is exactly what I meant, but you are much clearer. I hope this can 
> be made to work!
> 

My two cents are against this kind of design. 
The "correct" approach IMO is a 'universal text' type which is a _container_ of said text. This type would provide ranges for the various abstraction levels. E.g. 
text.codeUnits to iterate by codeUnits

Here's a (perhaps contrived) example:
Let's say I want to find the combining marks in some text. 

For instance, Hebrew uses combining marks for vowels (among other things) and they are optional in the language (There's a "full" form with vowels and a "missing" form without them).
I have a Hebrew text with in the "full" form and I want to strip it and convert it to the "missing" form. 

How would I accomplish this with your design? 



More information about the Digitalmars-d mailing list