cas function issue

2011-12-29 Thread Adrian Mercieca
Hi folks, I've got this very simple program, for which I keep getting compiler errors at the 'cas' function call. import std.stdio, core.atomic; class Int { public: this(int v) { this._v = v; } private: int _v; } void main() {

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jacob Carlborg
On 2011-12-29 18:22, Jakob Ovrum wrote: On Thursday, 29 December 2011 at 16:27:33 UTC, Ashish Myles wrote: std.c.stdlib.exit() seems to break RAII. The code below tests this both using a struct destructor and an explicit scope(exit) {}. Is this an intentional feature or a bug? import

Re: Using delegate for WindowProc - possible ?

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

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Andrej Mitrovic
Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(), throwing will take care of RAII stuff.

Re: Using delegate for WindowProc - possible ?

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

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(), throwing will take care of RAII stuff. Thanks, Andrej. That option had

Re: Reading about D: few questions

2011-12-29 Thread Mr. Anonymous
On 25.12.2011 11:28, Denis Shelomovskij wrote: OK. As I wrote: Yes, this allocation sometimes can be optimized out but not always.. Consider this: --- void main() { int[] a = new int[5]; void f(int[] b) { // Here we assume that b is unchanged a. // As these array differ we need a copy.

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jakob Ovrum
On Thursday, 29 December 2011 at 16:27:33 UTC, Ashish Myles wrote: std.c.stdlib.exit() seems to break RAII. The code below tests this both using a struct destructor and an explicit scope(exit) {}. Is this an intentional feature or a bug? import std.stdio; import std.c.stdlib; void main() {

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jakob Ovrum
On Thursday, 29 December 2011 at 17:22:33 UTC, Jakob Ovrum wrote: Calling 'exit' doesn't properly shut down the D runtime either, it's not just constructors. I mean destructors*.

Re: cas function issue

2011-12-29 Thread Adrian Mercieca
On Thu, 29 Dec 2011 08:01:51 +, Adrian Mercieca wrote: Hi folks, I've got this very simple program, for which I keep getting compiler errors at the 'cas' function call. import std.stdio, core.atomic; class Int { public: this(int v) { this._v =

Re: Are D classes always garbage collected?

2011-12-29 Thread Ali Çehreli
On 12/21/2011 10:20 PM, Froglegs wrote: Which returned me a nice fat null pointer.. wth? Perhaps that should be a compile time error if you aren't supposed to use classes.. Strange... I'm not sure what the deal is with that overload. I meant the last one on the page (that takes a void[]).

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread AaronP
On 12/29/2011 12:43 PM, Ashish Myles wrote: On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(), throwing will take care of

Re: Using delegate for WindowProc - Is possible and fun!

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

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Jonathan M Davis
On Thursday, December 29, 2011 13:43:36 Ashish Myles wrote: On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Probably the easiest thing to do is to throw a custom exception and catch it somewhere in main() to return your status code. Unlike exit(),

Re: Bug or feature? std.c.stdlib.exit() breaks RAII

2011-12-29 Thread Ashish Myles
On Thu, Dec 29, 2011 at 7:16 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: A D exit function would have to do essentially the same thing as throw an exception and catch it in main anyway. The only way that the stack is going to be unwound properly is if you actually unwind it. The only way

Re: Using delegate for WindowProc - possible ?

2011-12-29 Thread Juan Campanas
On Thursday, 29 December 2011 at 20:08:45 UTC, bls wrote: import std.stdio; import std.functional; int main(string[] argv) { extern(Windows) int delegate( int i) dg; alias dg callback; callback = toDelegate(test);