I did not read all the discussion in detail, but in my opinion something that would be very useful in a library is

struct String{
        void *ptr;
        size_t _l;
        enum :size_t {
                MaskLen=((~cast(size_t)0)>>2)
        }
        enum :int {
                BitsLen=8*size_t.sizeof-2
        }
        size_t len(){
                return (_l & MaskLen);
        }
        int encodingId(){
                return cast(int)(_l>>BitsLen);
        }
}

plus stuff to simplify its creation from T[] arrays and getting T[] arrays from it.

this type would them be used where one wants a string without caring about its encoding, and without having to make all string accepting functions templates.
As it was explained by others many string operations are rather generic.
*this* is what I would have expected from string, not an alias to char[].

Fawzi
        

Reply via email to