digitalmars.D - noreturn ?
- bearophile (22/22) Dec 24 2011 C1X (C11), the successor of C99, is now designed, among its changes ther...
- Vladimir Panteleev (2/6) Dec 24 2011 How about: scope(success) assert(0); ?
- Andrei Alexandrescu (6/12) Dec 24 2011 The attribute should be migrated to the signature of the function such
- Jonathan M Davis (10/24) Dec 25 2011 It's the sort of thing that we could add at any time without breaking
- Caligo (3/6) Dec 24 2011 Functions are like people. Sometimes they go places that's so beautiful
C1X (C11), the successor of C99, is now designed, among its changes there is _Noreturn, this is what the latest free draft says about it: A function declared with a _Noreturn function specifier shall not return to its caller. The implementation should produce a diagnostic message for a function declared with a _Noreturn function specifier that appears to be capable of returning to its caller. _Noreturn void f () { abort(); // ok } _Noreturn void g (int i) { // causes undefined behavior if i<=0 if (i > 0) abort(); } #include <setjmp.h> _Noreturn void longjmp(jmp_buf env, int val); #include <stdlib.h> _Noreturn void abort(void); #include <stdlib.h> _Noreturn void exit(int status); #include <stdlib.h> _Noreturn void _Exit(int status); #include <stdlib.h> _Noreturn void quick_exit(int status); GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a noreturn function attribute useful in D too? Maybe to implement a better halt assert(0)? Bye, bearophile
Dec 24 2011
On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote:GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a noreturn function attribute useful in D too? Maybe to implement a better halt assert(0)?How about: scope(success) assert(0); ?
Dec 24 2011
On 12/24/2011 06:58 PM, Vladimir Panteleev wrote:On Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote:The attribute should be migrated to the signature of the function such that calling code can take advantage of it. I personally think this is a small matter. Right now we have bigger rocks to move. It would be great if 2.058 had all [tdpl] bugs fixed. AndreiGNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a noreturn function attribute useful in D too? Maybe to implement a better halt assert(0)?How about: scope(success) assert(0); ?
Dec 24 2011
On Saturday, December 24, 2011 22:26:02 Andrei Alexandrescu wrote:On 12/24/2011 06:58 PM, Vladimir Panteleev wrote:It's the sort of thing that we could add at any time without breaking backwards compatibility, so there's no rush unless it solves a burning problem. But at best, it solves a minor inconvenience. Solving the TDPL on the other hand would resolve a major usability issue for the language - particularly how it affects newbies reading TDPL. But completely aside from the newbies, it's a major milestone in actually having the full language implemented so that there's a lot less of a distinction between the design and the implementation. - Jonathan M DavisOn Saturday, 24 December 2011 at 20:09:46 UTC, bearophile wrote:The attribute should be migrated to the signature of the function such that calling code can take advantage of it. I personally think this is a small matter. Right now we have bigger rocks to move. It would be great if 2.058 had all [tdpl] bugs fixed.GNU C has a noreturn attribute since a lot of time. I don't fully understand why such attribute is so useful in C programs, but is something like a noreturn function attribute useful in D too? Maybe to implement a better halt assert(0)?How about: scope(success) assert(0); ?
Dec 25 2011
On Sat, Dec 24, 2011 at 2:09 PM, bearophile <bearophileHUGS lycos.com>wrote:I don't fully understand why such attribute is so useful in C programs Bye, bearophileFunctions are like people. Sometimes they go places that's so beautiful that they never want to return.
Dec 24 2011