Let's schedule WinAPI ASCII functions for deprecation!

Walter Bright newshound2 at digitalmars.com
Tue May 22 13:41:17 PDT 2012


On 5/22/2012 11:11 AM, Denis Shelomovskij wrote:
> Since Win9x isn't supported any more why do we have ASCII WinAPI functions in
> druntime's core.sys.windows.windows (and, possibly, other places)?
>
> Reasons against *A functions:
> * using of every such function is unsafe (with really seldom exceptions like
> LoadLibraryA("ntdll")) because inability to encode non-ASCII characters to OEM
> encoding will almost always give unpredictable results for programmer (simple
> test: you, reader, what will happen?);
> * in D it's too easy to make a mistake by passing UTF-8 string pointer to such
> function because D has no string types other than UTF and elimination of such
> function is the only solution unless ASCII string type is created
> * it performs worse because Windows has to convert ASCII string to UTF-16 first
>
> And yes, druntime already has encoding bugs because of using such functions.

First off, I agree that druntime and phobos must not use the A functions without 
a very, very good reason.

Secondly, as a matter of principle, we are not going to fix, improve, refactor, 
or re-engineer the Windows API, nor any other operating system API, nor the C 
Standard Library, no matter how tempting that may be. The job of the D interface 
modules is to simply provide an interface to them, as thin and direct as 
possible, without editorial comment. The user can decide what to use or not use 
from it.



More information about the Digitalmars-d mailing list