On 6/21/11, bearophile <bearophileh...@lycos.com> wrote: > I am not asking you to modify the code, but D with() was designed to reduce > noise in code like: > > wndclass.style = CS_HREDRAW | CS_VREDRAW; > wndclass.lpfnWndProc = &WndProc; > wndclass.cbClsExtra = 0; > wndclass.cbWndExtra = 0; > wndclass.hInstance = hInstance; > wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); > wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); > wndclass.hbrBackground = cast(HBRUSH) GetStockObject(WHITE_BRUSH); > wndclass.lpszMenuName = appName.toUTF16z; > wndclass.lpszClassName = appName.toUTF16z;
Yes, the original code is quite noisy, especially considering that a lot of code uses pointers and state variables for strcpy calls and things like that. > > The code in those examples is generally very noisy (I presume about as much > as the original code). I have mixed feelings about it. Yes, it's noisy because of a couple of things: 1. I haven't worked a lot on actually using D idioms. My main concern was making the examples compile and work in the exact way as the original examples. Having a 1-to-1 translation helps in catching bugs (and I've had quite a few of those). 2. Generally calling into GDI is going to be much more noisy than using some 3rd party GUI library, the same goes for various other WinAPI functions as well. You have to manually acquire and release GDI resources so this complicates things. 3. I've added some excessive noise in some code since I've used a lot of to!string() and duplication workarounds to get the examples compiling. This will be replaced with better code. The examples will be continued to be improved and refactored, but I had to start hosting them otherwise I'd never finish the project.