review request for 7008728: diamond conversion of basic security, permission, authentication code
Stuart Marks
stuart.marks at oracle.com
Fri Dec 31 03:26:06 UTC 2010
On 12/29/10 8:28 AM, Sean Mullan wrote:
> I don't really have a strong opinion, but I might be annoyed if there were a
> complex set of guidelines as to when to use the diamond operator and when not
> to. Anyway, maybe we should see if the JSR 334 expert group has any additional
> thoughts?
I talked to Joe Darcy (JSR 334 spec lead) about this. The expert group is
forming just now, and their main priority is on the Coin specification. It's
possible they could have some input at some point, but it might not be for a while.
I think we're the first ones to put diamond to large-scale use in production
code, so we're running into things that haven't been encountered in toy
programs thus far. That's one of the goals of this exercise. Of course, the
compiler/language guys have thought about all kinds of edge cases, but from the
point of view of the language definition, not how things work out in real code.
To this end, I spent some time going over a number of issues with Alex Buckley
and with Brad Wetmore yesterday. You and Brad had both raised questions about
using the diamond operator in assignment statements, where the variable's type
declaration is potentially quite far away. Brad said that he thought this
reduced the readability of the program. Given this, I'm leaning toward avoiding
use of diamond in assignment statements (where the variable is declared elsewhere).
You and I had also noticed a couple places where the diamond converter had
apparently missed an opportunity to do a conversion. The reasons are too
complicated to explain here, but in both cases the conversion wasn't done
because the compiler's inference algorithm couldn't actually infer the right
type. Even in the similar cases where the inference could be done, where the
conversion was applied, the inference was actually quite subtle. If it's subtle
to the compiler, it's probably also subtle to the programmer, so in those cases
I'd also recommend avoiding the diamond operator.
There are still a lot of places where diamond can be used in a fairly obvious
fashion, such as initializers in variable declarations, the most common case.
I'll update the changes and send out a revised set of webrevs next week.
s'marks
More information about the security-dev
mailing list