Proposal for fixing dchar ranges

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 10 08:07:09 PDT 2014


On Mon, 10 Mar 2014 10:54:50 -0400, H. S. Teoh <hsteoh at quickfur.ath.cx>  
wrote:


> The only concern I have is the current use of char[] and const(char)[]
> as mutable strings, and the current implicit conversion from string to
> const(char)[]. We would need similar wrappers for char[] and
> const(char)[], and string and mutablestring must be implicitly
> convertible to conststring, otherwise a LOT of existing code will break
> in a major way.

I agree that is a limitation of the proposal. It's more of a language-wide  
problem that one cannot make a struct that can be tail-const-ified.

One idea to begin with is to weakly bind to immutable(char)[] using alias  
this. That way, existing code devolves to current behavior. Then you pick  
off the primitives you want by defining them in the struct itself.

> Plus, these wrappers should also expose the same dchar
> range API with .representation giving a way to get at the raw code
> units.

It already does that, representation is a public member.

-Steve


More information about the Digitalmars-d mailing list