Feature request: custom default annotation attributes
Brian Goetz
brian.goetz at oracle.com
Sun Nov 21 19:01:13 UTC 2021
While I'm the first to admit that the design of annotations incorporated
a great deal of optimism about its sufficiency, I think the
return-on-complexity for such things is not good enough to warrant
working on this.
> Now I was thinking: wouldn't it be nice to be able to define a custom
> default attribute? That could be done using an annotation, let's call
> it @DefaultAttribute.
Actually it can't. The cardinal design principle of annotations is:
they do not affect language semantics. So you'd need actual language
support here (such as marking the default attribute with a keyword like
"default-attribute".) That's not impossible, but there's clearly a host
of conditions and interactions to deal with. Yes, they're mostly
trivial, but there's always more of them than one imagines at first.
But if we do this feature (which seems trivial, but no language feature
is trivial), we're implicitly deciding to delay or not do some other
feature. And the other features on the menu all offer a much greater
return.
(Such features are like single-purpose kitchen appliances; a countertop
hot-dog cooker might be the best way to make hot dogs, but single-use
appliances usually offer a pretty poor return on counter space. (Except
the rice cooker; that's the one single-purpose appliance we have in our
house, and I wouldn't give it up.))
So, given an infinite budget for implementation, language surface, and
complexity, its not something I'd rule out because its terrible
(clearing this bar is actually pretty good), but realistically I don't
see it coming near the top of the list of features we'd want to invest in.
More information about the core-libs-dev
mailing list