On 25/11/2015 3:27 AM, Vitaly Davidovich wrote:
The choice of reachabilityFence was in part motivated by hearing
about mistakes in using C# keepAlive where people would place keepAlive
before uses of fields, rather than after them. A more accurate name
should reduce this error in Java.
I don't see how reachabilityFence would help prevent that type of
mistake/usage. Having used KeepAlive in .NET, I personally think it's a
better and more appropriate name and has the "demarcation" aspect (i.e.
"keep this alive until the point where I wrote KeepAlive"). But, it's a
bikeshed so I won't get hung up on it.
KeepAlive sounds like it might "tag" the reference in some way so that
it is always kept alive with a scope - and hence suggests incorrect usage:
Foo f = ...
Reference.keepAlive(f);
...
// oops f not live here after all
keepAliveAtLeastTillHere would be more explicit. reachabilityFence has
no obvious intepretation so one is forced to consult the documentation
and check one is using it correctly. :)
Cheers,
David
On Tue, Nov 24, 2015 at 12:06 PM, Doug Lea <d...@cs.oswego.edu> wrote:
On 11/24/2015 09:09 AM, Andrew Haley wrote:
Bikeshedding,
On 11/24/2015 01:07 PM, Vitaly Davidovich wrote:
How about keepAlive? Reference.keepAlive(Object) reads better, IMO.
It does indeed. Imperative names for methods almost always read better,
IMO. And although we probably don't don't much care about C#, it too
uses the name KeepAlive() for this.
Well, it is not an imperative notion, it is a demarcation.
More like a semicolon than an action. (Which is the realm of fences.)
The choice of reachabilityFence was in part motivated by hearing
about mistakes in using C# keepAlive where people would place keepAlive
before uses of fields, rather than after them. A more accurate name
should reduce this error in Java.
-Doug