Hi Tobias,
>>> On 23.11.2017 at 13:31, Tobias Koeck <tobias.ko...@gmail.com> wrote:
[...]
> just checked it out. It's possible to create a local variable with
> 
> locals.temp = a * b
> instead of
> var temp = a * b.

great, that you shared your test-results. Thanks.

> The usage of the keywords locals, this and globals aren't necessary just
> for readability. As far as I have read there is a priority from locals to
> this to globals variables. If you just write
> 
> 'something ...' = temp
> 
> it will check out the different scopes and gets the first that fits.

That's correct. You know it, Icinga2 knows it. Some other girl/guy, reading 
your config may not know it. So even when accessing a local variable, it may be 
good practice, to prepend it with "locals." when you have variables with the 
same name in different scopes. With "just for readability" I only meant your 
special case of using "locals" for a local variable.

> With the keyword you can force Icinga 2 to take a specific scope variable.

Jepp. Again, if you have a variable with the same name in global- and in 
local-scope, you have to prepend it with "globals.", to acces the one in the 
global-space. You dont' have to use "locals." to access the one in the local 
scope, but you CAN if you whish.

Hope I clarified it a little.

best regards
Kai



_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to