What is the function parameter area in qore?

I am a little puzzled by the variable scope in qore 0.8.12. It seems that the function parameters have the same scope as the global variables - is this possible, or am I doing something wrong?

3.1.0 kveton@kvela ~$ cat zk1.q %new-style %strict-args sub fun(string v) { print("xxx\n"); } string v = "zzz"; 3.1.0 kveton@kvela ~$ qore zk1.q unhandled QORE System exception thrown in TID 1 at 2017-01-30 08:10:32.612137 Mon +01:00 (CET) at zk1.q:4 PARSE-ERROR: local variable 'v' was already declared in the same block at zk1.q:9 

Thanks for the explanation...

+5
source share
1 answer

Local variables in the top-level area are global global flow variables.

See:

This makes it impossible to use the same variable name as the parameter variable (which is a local variable in the scope of a function, method, or closure).

+6
source

Source: https://habr.com/ru/post/1263562/


All Articles