No we should not support enum types derived from strings

guai guai at inbox.ru
Sat May 8 16:04:24 UTC 2021


On Friday, 7 May 2021 at 22:34:19 UTC, Jon Degenhardt wrote:
> `byLine` implementations will usually work by iterating 
> forward, but there are random access use cases as well. For 
> example, it is perfectly reasonable to divide a utf-8 array in 
> roughly in half using byte offsets, then searching for the 
> nearest utf-8 character boundary. At after this both halves are 
> treated as utf-8 input ranges, not random access.

In my experience treating a string as byte array is almost never 
a good thing. Person doing it must be very careful and truly 
understand what they are doing.
What are those use cases other than `byLine` where this is useful?
Dividing utf-8 array and searching for the nearest char may split 
inside a combining character which isn't a thing you usually 
want. Especially when human would read this text.
Conceptually string is a sequence of characters. A range of dchar 
in D's terms.


More information about the Digitalmars-d mailing list