Re: Arrray sizeof

2011-12-28 Thread Regan Heath
On Sat, 24 Dec 2011 16:46:18 -, RenatoL rex...@gmail.com wrote: snippet: int[] arr1 = [1,2,3,4,5]; int[5] arr2 = [1,2,3,4,5]; writeln(arr1.sizeof); writeln(arr2.sizeof); Output: 8 20 0 is ok to me but why 8?? It's a quirk of D that int[] is a reference type, so you get the size of

do-while loops

2011-12-28 Thread bearophile
One thing that I often find not handy in the design of do-while loops: the scope of their body ends before the while: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } So I can't define inside them variables that I test in the while(). This

Re: do-while loops

2011-12-28 Thread Timon Gehr
On 12/28/2011 02:29 PM, bearophile wrote: One thing that I often find not handy in the design of do-while loops: the scope of their body ends before the while: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } So I can't define inside them

Re: do-while loops

2011-12-28 Thread Andrej Mitrovic
A very small cheat: void main() { if (int x = 0) do { x = 5; } while (x != 5); } Only works for this simple case though. Put your post in d.general, I totally agree with it as well.

Re: do-while loops

2011-12-28 Thread Timon Gehr
On 12/28/2011 04:01 PM, Andrej Mitrovic wrote: A very small cheat: void main() { if (int x = 0) do { x = 5; } while (x != 5); } Only works for this simple case though. Put your post in d.general, I totally agree with it as well. This won't work. The 'if' condition is

Re: do-while loops

2011-12-28 Thread Xinok
On 12/28/2011 8:29 AM, bearophile wrote: One thing that I often find not handy in the design of do-while loops: the scope of their body ends before the while: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } I would just rewrite it like

Re: do-while loops

2011-12-28 Thread bearophile
Timon Gehr: I fully agree, but why does this go to D.learn? Because I think there's no hope to see this situation changed :-) Bye, bearophile

Re: do-while loops

2011-12-28 Thread Timon Gehr
On 12/28/2011 06:42 PM, bearophile wrote: Timon Gehr: I fully agree, but why does this go to D.learn? Because I think there's no hope to see this situation changed :-) Bye, bearophile Why? The only D code that would get broken would be code that uses a global variable in the loop

Re: do-while loops

2011-12-28 Thread Denis Shelomovskij
28.12.2011 16:29, bearophile пишет: One thing that I often find not handy in the design of do-while loops: the scope of their body ends before the while: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } So I can't define inside them

Re: do-while loops

2011-12-28 Thread Alex Rønne Petersen
On 28-12-2011 18:50, Timon Gehr wrote: On 12/28/2011 06:42 PM, bearophile wrote: Timon Gehr: I fully agree, but why does this go to D.learn? Because I think there's no hope to see this situation changed :-) Bye, bearophile Why? The only D code that would get broken would be code that

Re: do-while loops

2011-12-28 Thread Timon Gehr
On 12/28/2011 09:32 PM, Alex Rønne Petersen wrote: On 28-12-2011 18:50, Timon Gehr wrote: On 12/28/2011 06:42 PM, bearophile wrote: Timon Gehr: I fully agree, but why does this go to D.learn? Because I think there's no hope to see this situation changed :-) Bye, bearophile Why? The only

Re: do-while loops

2011-12-28 Thread Jonathan M Davis
On Wednesday, December 28, 2011 21:37:56 Timon Gehr wrote: Well, do loops are the least frequently used looping constructs. Also, if you actually have code like the following import foo; // defines global symbol 'x' void main(){ do { int x; // ...

Re: do-while loops

2011-12-28 Thread Manfred Nowak
bearophile wrote: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } Do you mean, that the similar while-loop should also be okay? | void main() { | while (x != 5) /* uses `x' out of _following_ scope */ { | int x = 5; | };

Re: do-while loops

2011-12-28 Thread Timon Gehr
On 12/28/2011 10:45 PM, Manfred Nowak wrote: bearophile wrote: void main() { do { int x = 5; } while (x != 5); // Error: undefined identifier x } Do you mean, that the similar while-loop should also be okay? | void main() { | while (x != 5) /* uses `x' out of

Using delegate for WindowProc - possible ?

2011-12-28 Thread Tal
Can I do something like this : __ extern (Windows) LRESULT delegate (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) MyWinProcDelegate; this() { MyWinProcDelegate = Events; } extern (Windows) LRESULT Events (HWND

Re: Using delegate for WindowProc - possible ?

2011-12-28 Thread Juan Campanas
On Wednesday, 28 December 2011 at 23:45:05 UTC, Tal wrote: Can I do something like this : __ extern (Windows) LRESULT delegate (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) MyWinProcDelegate; this() {