Discussion Thread: DIP 1032--Function pointers and Delegate Parameters...--Community Review Round 1
tsbockman
thomas.bockman at gmail.com
Sat Apr 4 13:14:22 UTC 2020
On Saturday, 4 April 2020 at 11:40:26 UTC, H. S. Teoh wrote:
> ...
> IOW, the effective attributes of a function call is the least
> permissive among the function itself and its delegate arguments.
This is exactly the behaviour that I want.
In general, every function should be annotated by default with
the the strongest gaurantees which the compiler can verify that
it actually fulfills. There are only two exceptions to this rule,
I think:
A) When insufficient information is available to the compiler to
determine if a restrictive (strong gaurantee) attribute applies,
the programmer may need to supply the right answer explicitly, as
in the case of @trusted, or of abstract and extern functions
whose body is not available for analysis.
B) When the author of a public API chooses to explicitly relax
these gaurantees in order to avoid exposing private
implementation details and accidentally turning changes to
otherwise encapsulated details into breaking API changes.
Currently, I find D's rules for attribute defaults and scoping so
far out of sync with the logical system above that I've mostly
given up on it and just explicitly annotate EVERYTHING I can.
This is fairly painful due to the visual noise and the lack of
negative attributes like "impure".
The semantics of D's attribute system are great - a major selling
point of the language, to me - but the syntax is terribly
awkward, verbose, and inconsistent.
More information about the Digitalmars-d
mailing list