Re: Is there a way to replace Exception with as a macro in C?

2019-02-18 Thread Marco de Wild via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 05:50:04 UTC, yisooan wrote: I wonder there is the way as I said in the title. For instance, in C, #define indexInvalidException Exception("The index is invalid") /* Do something with the macro here */ if (false) indexInvalidException; This is allowed. But

Re: Is there a way to replace Exception with as a macro in C?

2019-02-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 06:16:59 UTC, Mike Parker wrote: ``` Exception invalidIndexException() { throw new Exception("Index is invalid"); } Eh, that should be: void invalidIndexException() {...}

Re: Is there a way to replace Exception with as a macro in C?

2019-02-18 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 05:50:04 UTC, yisooan wrote: This is allowed. But I want to do the exact same thing in D. I have already tried some expressions with alias? but it doesn't work. alias can't be used for expressions. Would you help me, please? There's nothing exactly

Is there a way to replace Exception with as a macro in C?

2019-02-18 Thread yisooan via Digitalmars-d-learn
I wonder there is the way as I said in the title. For instance, in C, #define indexInvalidException Exception("The index is invalid") /* Do something with the macro here */ if (false) indexInvalidException; This is allowed. But I want to do the exact same thing in D. I have already tried