Google's Go & Exceptions

bearophile bearophileHUGS at lycos.com
Tue Jan 26 08:39:56 PST 2010


Justin Johansson:
> So to counter the dsimcha's point, my solution does
> not assume a default situation of ignoring errors. The thrust
> of my argument is that exceptions are not an all-or-nothing
> approach in sane dealing in errors.

In GCC there is also the "warn_unused_result" function attribute that raises a compile time warning if you don't use the return value of a function:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bwarn_005funused_005fresult_007d-attribute-2444

You can use it to be more sure you are reading and using an error return value.
Ideally you can invent a similar "error_unused_result" that raises an error instead.
(Some other of those GCC attributes can be useful in D2).

Bye,
bearophile



More information about the Digitalmars-d mailing list