Higher level built-in strings

Jonathan M Davis jmdavisprog at gmail.com
Tue Jul 20 11:00:12 PDT 2010


On Tuesday, July 20, 2010 05:30:51 DCoder wrote:
> I'm wondering how bad would it be introduce a schar (short char, 1
> byte) type and then let char simply map to a "default" char type:
> dchar, wchar, or whatever we tell the compiler. By default, char
> would map to dchar.
> 
> alias char dchar;
> 
> Coupling this with implicit cast of schar/char (from imported C
> code) to dchar, I think this might even help fix many such
> situations.

That doesn't really gain us anything. It would likely just make it so that char 
would mean dchar and be used by default. And honestly, using dchar is not really 
the solution. If you wan to do that, you can. However, using dchar in the 
general case is not necessarily a good idea since it wastes so much space.

On top of all that, TDPL was _very_ clear on the differences between char, wchar, 
and dchar and TDPL is supposed to stay accurate. So, any changes which would 
contradict TDPL need a _very_ good reason for being made, or they won't be.

Overall, strings in D work great. The only issue really is making it so that you 
properly deal with the cases where you need to treat them as code points vs when 
you can treat them as code units. Any programmer who wants to entirely avoid the 
problem can just using dchar and dstring. For the rest, you need to understand 
how string and wstring work and just handle them appropriately. There may be a 
few places where things should be smoothed out, but overall, I really do think 
that they work well as they are.

- Jonathan M Davis


More information about the Digitalmars-d mailing list