auto attribution pros/cons
Bruce Carneal
bcarneal at gmail.com
Sun Jun 28 18:39:13 UTC 2020
int afunc(int x) @nogc nothrow pure @safe { return x; } // fully
attributed
int func(int x) { return x; } // a vanilla function
int tfunc()(int x) { return x; } // trivially templated
int main() @nogc nothrow pure @safe {
// return afunc(0); // works
return tfunc(0); // also works
// return func(0); // fails to compile
}
Since tfunc() works today in the above, we know that much of the
machinery
for "auto attribution" exists. What are the pros/cons of enabling
auto attribution for vanilla functions?
Here are a few cons:
1) Some additional complexity in the compiler. How much?
2) Some additional complexity in IDEs. How much?
3) Could expose additional challenges for separate compilation.
Here are a few pros:
1) Extends the "it just works" envelope.
2) Allows explicit attribute requirements to move to a higher
level.
3) Enables wider code reuse.
4) Removes clutter. (minor but who loves attribute soup?)
5) Lessens the importance of language level attribute defaulting.
Corrections to the above? Better terminology? Other pros/cons?
Note: the auto attribution idea is not original, I've just not
seen it reviewed.
More information about the Digitalmars-d
mailing list