groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: Closure does not see field when setting value
Date Wed, 09 Nov 2016 18:24:16 GMT
On 08.11.2016 22:21, Krzysztof Kowalczyk wrote:
> Ok, thanks.
> So that would make this.x reference works as expected but still x = 1
> would work in surprising way. Why to allow creation of new bindings in
> this way at all? Reading bindings, fine, but creating new? To share them
> with outside world?

because a script "x = 1" is supposed to work out of the box. You could 
always have a different script base class.

> The behaviour is surprising to me in 2 ways:
> First, I do create a new thing even though it "exists".

Binding does not care what already exists.

> Second, if I compile it in static way it will behave differently.

and static compilation does not care about dynamic behaviours.

> @CompileStatic should behave as I want (I guess), but I can't easily
> apply @CompileStatic to a script, can I?

This and 
this might 
be interesting to you

bye Jochen

View raw message