Re: Defining a global variable

2020-10-23 Thread Anton Shepelev
Merlin Beedell: > I sure wish the word 'global' was used instead of > 'static'. It just kinda makes more sense to me! Those are orthogonal concepts. `static' denotes an element whose existance is with the program, and `dynamic' -- an element whose existance is with an instance of a dymamic obje

Re: Defining a global variable

2020-10-21 Thread MG
Or just //=== void func() { println(test) } test = 'hello' func() //=== Merlin Beedell -Original Message- From: MG Sent: 15 October 2020 6:21 PM To: users@groovy.apache.org; Jochen Theodorou Subject: Re: Defining a global variable On 15/10/2020 18

RE: Defining a global variable

2020-10-21 Thread Merlin Beedell
er 2020 6:21 PM To: users@groovy.apache.org; Jochen Theodorou Subject: Re: Defining a global variable On 15/10/2020 18:27, Jochen Theodorou wrote: > well.. even scripts are first compiled into a class before the class > is then executed. Groovy has no interpreter Which, I think, is a lesse

Re: Defining a global variable

2020-10-15 Thread MG
On 15/10/2020 18:27, Jochen Theodorou wrote: well.. even scripts are first compiled into a class before the class is then executed. Groovy has no interpreter Which, I think, is a lesser known fact, and quite surprising to people who perceive Groovy just under its "script language" aspect ;-)

Re: Defining a global variable

2020-10-15 Thread Jochen Theodorou
On 15.10.20 12:16, Anton Shepelev wrote: Jochen Theodorou to Anton Shepelev: Jochen Theodorou: Frankly... for years we have been defending this position, but now, with so much distance I actually really wonder why we keep this. Perhaps it would have helped if you had documented not only lan

Re: Defining a global variable

2020-10-15 Thread Anton Shepelev
Jochen Theodorou to Anton Shepelev: > > Jochen Theodorou: > > > > > Frankly... for years we have been defending this > > > position, but now, with so much distance I actually > > > really wonder why we keep this. > > > > Perhaps it would have helped if you had documented not > > only language feat

Re: Defining a global variable

2020-10-14 Thread Jochen Theodorou
On 14.10.20 17:01, Anton Shepelev wrote: Jochen Theodorou to Anton Shepelev: [...] Frankly... for years we have been defending this position, but now, with so much distance I actually really wonder why we keep this. Perhaps it would have helped if you had documented not only language features

Re: Defining a global variable

2020-10-14 Thread Anton Shepelev
Jochen Theodorou to Anton Shepelev: > > String test > > > > void func() > > { > >println(test) > > } > > > > test = 'hello' > > func() > > > > Why, then, is `test' inaccessible from the function in > > my script? > > because the method you defined is not nested in another > method, instead it

Re: Defining a global variable

2020-10-14 Thread Maarten Boekhold
Hi, I've been caught out by this in the past as well. It's actually quite simple... A Groovy Script like: String test void func(){     println(test) } test = 'hello' func() Gets compiled to a class as: class MyScript extends Script {     def run() {         Str

Re: Defining a global variable

2020-10-14 Thread Jochen Theodorou
On 14.10.20 13:45, Anton Shepelev wrote: [...] String test defienes a string property `test' or a string variable `test', depending on context. the context here is that of a method, so it is a local variable I was now stuck and resorted to an internet search, which brought up the followi

Defining a global variable

2020-10-14 Thread Anton Shepelev
Hello, all I tried to define a global variable in a Groovy script. Section 1.1. of the "Semantics" documents says that one way to define a variable is via its type, so I defined one in the global scope of my script: String test void func() { println(test) } test = 'hello'