Never-returning functions

2016-08-02 Thread Enamex via Digitalmars-d-learn
I've tried to write an 'assert function' in D, one that doesn't trigger the 'function must return a value or assert' error. Basically something like: Never neverReturns() { assert(0); } or @noreturn auto neverReturns() { assert(0); } and int tryMe(bool f) { if(f) return 42; else nev

Re: Never-returning functions

2016-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/16 11:09 AM, Enamex wrote: I've tried to write an 'assert function' in D, one that doesn't trigger the 'function must return a value or assert' error. Basically something like: Never neverReturns() { assert(0); } or @noreturn auto neverReturns() { assert(0); } and int tryMe(bool f) {

Re: Never-returning functions

2016-08-02 Thread ketmar via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer wrote: What's wrong with assert(0) that you need to have a wrapper function for it? while this is a legitimate question, the comipler's inability to infer "noreturn" still drives me mad. but if compiler will suddenly be able to i

Re: Never-returning functions

2016-08-02 Thread Enamex via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer wrote: What's wrong with assert(0) that you need to have a wrapper function for it? -Steve Nothing wrong exactly. I just wanted some descriptive terms to use in some places. Like "unreachable()" or "unimplemented()". To be cle

Re: Never-returning functions

2016-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/2/16 11:34 AM, Enamex wrote: On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer wrote: What's wrong with assert(0) that you need to have a wrapper function for it? -Steve Nothing wrong exactly. I just wanted some descriptive terms to use in some places. Like "unreachable()"