Enforcing checks for return code
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 18 02:16:32 PST 2016
On Thursday, February 18, 2016 07:21:05 Chris Katko via Digitalmars-d-learn wrote:
> Hello. I'm almost brand-new to the D language and still absorbing
> things.
>
> I'm wondering if it's possible to fire off a compile-time (or
> worst case, a run-time) warning or error if a function is called,
> but the return value is not checked.
>
> I'm not trying to enforce whether someone actually deciphers the
> value's meaning correctly. I just want to enforce that somewhere,
> a variable or expression is receiving the return value of a
> particular function.
>
> Any ideas?
>
> I imagine I could use a compiler flag to warn, but that's a
> global setting. I'm looking more for a specified subset of
> functions.
D has no such feature, and very little D code is going to use return codes.
D has exceptions, and throwing an exception is the normal way to indicate
that there was a problem. You certainly _can_ choose to use error codes if
you'd like, but it's not normal practice, and the language does nothing
extra to support it.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list