Call-ie return on behalf of caller?

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 3 15:37:52 PDT 2015


Is there a way other than exceptions for a called function to 
force the caller to return?

Specifically, I know the return type of the caller(its always 
bool) and under certain circumstances I would like the caller to 
just give up and return false if the called function fails. With 
as little boiler plate as possible on the call site. In c++ I 
could do it very easily with macros, but I am failing to see a 
similar way to do it in D other than maybe string mixins but that 
seems like a bit much to do every time I want to call this thing.

I would be willing to put some boilerplate code in the beginning 
of the caller, I could just put that in a mixin.

I know exceptions are really what I should be using but they are 
such a pain to work with. I don't want to have to put try catch 
blocks every time I call the caller.

Any ideas?


More information about the Digitalmars-d-learn mailing list