Nice to @Share?
Neal Gafter
neal at gafter.com
Mon Feb 22 13:31:48 PST 2010
I agree with Josh on most of this. An annotation could be used as
long as it does not change the semantics. If it does change the
semantics (e.g. making something legal that would otherwise be
illegal, or vice versa) then an annotation is not the right mechanism.
His issues (1), (2), and (3) can be addressed by making violations of
the rule a warning rather than an error, as in CfJ
<http://javac.info/closures-v06a.html>.
As for the name, "shared" doesn't mean that the variable is shared
between threads. It means that the variable may be shared between the
method (or lambda) in which it is declared and any nested lambdas.
Re 'In practical terms, it means "this variable must *not* be shared
(without additional synchronization)."', this doesn't really make much
sense to me; all variables (whether marked @Shared or not) must not be
shared between threads (without additional synchronization).
Our comments are on text that is in the commentary in the current
draft. I presume that some upcoming revision of the draft spec will
provide some way to access variables from the enclosing scope that are
not morally final, but I'm willing to wait to see that revision to
pass judgment. If no such support appears, I expect to complain.
More information about the lambda-dev
mailing list