I have the problem that :return acts like an :error and terminates the function and does not execute the last command till the end of the function "}"
From the Wiki:
Starting from v6.2 new syntax is added to easier define such functions and even pass parameters. It is also possible to return function value with :return command
Talked about is that it should return the value but not that the function is terminated on the spot. I read it as, that the value is returned on exit of the function.
Now I have first transfer the :global values to a temporary :local and erase the :global ones and :return the locals. The :local ones are destroyed on exit of the function.
I could switch back complete local but during debugging the environment box shows the values of variables when the are set temporary to global.