Then you would force people to immediately convert a large number of their Java source files to correct Groovy, which I think would put people off.

What about introducing an explicit "property access" operator, as a counterpart to the existing field access one ?

E.g.

this.x / super.x  // Current, practical but in some cases not immediately obvious logic
this.@x / super.@x // Field access
this.#x / super.#x  // Always property, with auto-property (i.e. field access) fallback

That way one could express clearly one's intention, in the (in practice imho rare) case where this is necessary...


On 26/06/2020 17:33, Jochen wrote:
On 26.06.20 17:21, Jochen Theodorou wrote:
[...]
public class X {
   private String foo;
   public String getFoo(){ return this.foo; }
   public void setFoo(String foo){ this.foo = foo; }
}

This works perfectly fine in Java and would lead to a stack overflow in
Groovy as soon as you call the getter or setter. Since it is quite
common we have a problem here.

actually I am wondering.. what if we made this a compilation error?

bye Jochen


Reply via email to