Checking function parameters in Phobos

Lionello Lunesu lionello at lunesu.remove.com
Tue Nov 26 20:34:36 PST 2013


On 11/20/13, 18:45, Lars T. Kyllingstad wrote:
> I think we should use ubyte[] to a greater extent for data which is
> potentially *not* valid UTF.  Examples include interfacing with C
> functions, where I think there is a tendency towards always translating
> C char to D char, when they are in fact not equivalent.  Another example
> is, again, std.file.read(), which currently returns void[].  I guess it
> is a matter of taste, but I think ubyte[] would be more appropriate
> here, since you can actually use it for something without casting it first.

+1

Especially the windows APIs, they never take UTF-8(*) but consistently 
get translated to taking D char :(

In fact, if we want a good translation from C to D, we should be using D 
byte. On most platforms I've run into have C char is signed. (To be 
honest, you don't see 'byte' much in D code, so it would make the ported 
code stand out even more.)

* except from MultiByteToWideChar



More information about the Digitalmars-d mailing list