digitalmars.D.learn - Rosettacode: program termination
- bearophile (5/5) Apr 14 2014 I have added a D entry regarding how to terminate D programs.
- John Colvin (14/19) Apr 14 2014 I think notInifnite is too contrived, you would always just use
- bearophile (5/18) Apr 14 2014 OK, I have improved the code:
- Andrea Fontana (4/24) Apr 15 2014 What about:
- bearophile (4/6) Apr 15 2014 I have added it.
- Andrea Fontana (8/15) Apr 15 2014 http://dpaste.dzfl.pl/33cb0a05f0ff
- bearophile (7/14) Apr 15 2014 Well, we have a little mystery here :-) Using both the latest
- Andrea Fontana (9/25) Apr 15 2014 I think so. On dpaste using 2.063.2 or git version that function
- bearophile (7/15) Apr 15 2014 The C exit() function is not required to honour D module
I have added a D entry regarding how to terminate D programs. What's missing? http://rosettacode.org/wiki/Program_termination#D Bye, bearophile
Apr 14 2014
On Monday, 14 April 2014 at 09:58:09 UTC, bearophile wrote:I have added a D entry regarding how to terminate D programs. What's missing? http://rosettacode.org/wiki/Program_termination#D Bye, bearophileI think notInifnite is too contrived, you would always just use `else` there. This is more realistic: int notInfinite(in int b) pure nothrow { if (b < 0) return 10; if (b > 10) return 20; // In release mode this becomes a halt, and it's sometimes // necessary. If you remove this the compiler gives: // Error: function test.notInfinite no return exp; // or assert(0); at end of function assert(false); }
Apr 14 2014
John Colvin:I think notInifnite is too contrived, you would always just use `else` there. This is more realistic: int notInfinite(in int b) pure nothrow { if (b < 0) return 10; if (b > 10) return 20; // In release mode this becomes a halt, and it's sometimes // necessary. If you remove this the compiler gives: // Error: function test.notInfinite no return exp; // or assert(0); at end of function assert(false); }OK, I have improved the code: http://rosettacode.org/wiki/Program_termination#D Bye, bearophile
Apr 14 2014
On Monday, 14 April 2014 at 11:16:41 UTC, bearophile wrote:John Colvin:What about: static ~this() { "asdasdasd".writeln; } ?I think notInifnite is too contrived, you would always just use `else` there. This is more realistic: int notInfinite(in int b) pure nothrow { if (b < 0) return 10; if (b > 10) return 20; // In release mode this becomes a halt, and it's sometimes // necessary. If you remove this the compiler gives: // Error: function test.notInfinite no return exp; // or assert(0); at end of function assert(false); }OK, I have improved the code: http://rosettacode.org/wiki/Program_termination#D Bye, bearophile
Apr 15 2014
Andrea Fontana:What about: static ~this() { "asdasdasd".writeln; }I have added it. Bye, bearophile
Apr 15 2014
On Tuesday, 15 April 2014 at 09:30:21 UTC, bearophile wrote:Andrea Fontana:http://dpaste.dzfl.pl/33cb0a05f0ff Static destructor is called! Application output: spam at exit bar at exit foo at exit Never calledWhat about: static ~this() { "asdasdasd".writeln; }I have added it. Bye, bearophile
Apr 15 2014
Andrea Fontana:http://dpaste.dzfl.pl/33cb0a05f0ff Static destructor is called! Application output: spam at exit bar at exit foo at exit Never calledWell, we have a little mystery here :-) Using both the latest beta of ldc2 and the latest alpha of dmd, on Windows32 I don't see "Never called" called :-) Perhaps this incongruence is another little compiler bug? :-) Bye, bearophile
Apr 15 2014
On Tuesday, 15 April 2014 at 09:48:57 UTC, bearophile wrote:Andrea Fontana:I think so. On dpaste using 2.063.2 or git version that function isn't called. Only on 2.065.. More: import std.stdio; "Never called".writeln; This doens't work on git version (only in 2.065). I think it is a known behaviour about "local" import + ufcs. Why does it work on 2.065?http://dpaste.dzfl.pl/33cb0a05f0ff Static destructor is called! Application output: spam at exit bar at exit foo at exit Never calledWell, we have a little mystery here :-) Using both the latest beta of ldc2 and the latest alpha of dmd, on Windows32 I don't see "Never called" called :-) Perhaps this incongruence is another little compiler bug? :-) Bye, bearophile
Apr 15 2014
Andrea Fontana:I think so. On dpaste using 2.063.2 or git version that function isn't called. Only on 2.065..The C exit() function is not required to honour D module destructors.More: import std.stdio; "Never called".writeln; This doens't work on git version (only in 2.065). I think it is a known behaviour about "local" import + ufcs. Why does it work on 2.065?This code should work (because the imported names are not locally defined), and it correctly works with the latest dmd alpha :-) Bye, bearophile
Apr 15 2014