Summary: Attribute to not ignore function result
--- Comment #0 from bearophile_h...@eml.cc 2011-01-20 02:59:14 PST ---
Ignoring the result of some functions like string replace(), or the C
realloc(), or in general the result of strongly pure functions in D, is a
programmer mistake that often enough is a sign of a bug presence.
To face this problem GNU C has the warn_unused_result attribute:
(This is more useful in C than D because in C there are no true built-in
exceptions, so error return values are common, and sometimes ignoring them is a
Some C lints require a void cast where you don't want to use a function result:
In a language the default is different and where you don't want to use a
function result you have to add a specific annotation:
In D an attribute like @nodiscard (name invented by Andrej Mitrovic) may turn
ignoring return values into errors. To silence this error the programmer uses
something like cast(void).
So the error message may be:
"Error: unused result of @nodiscard function. Use cast(void) to override it."
Strongly pure functions may produce this error even if you don't use
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------