Neither local nor global variable

I accidentally wrote $ in front of the variable name in a :set statement and it worked:

:set $notdeclared 10

I use this in a function to set the default value of an optional argument:

:global myfun do={
	:if ([:typeof $optarg] = "nothing") do={ :set $optarg "default value"}
	:return $optarg
	}

But also works in .rsc files:

:put $myvariable
:set $myvariable 10
:put $myvariable

Can somebody give some information about this feature?

(tested on Ros 6.25 and 7.7)

“substitution operator”
https://help.mikrotik.com/docs/display/ROS/Scripting#:~:text=substitution%20operator

“Undefined variables will be marked as undefined and will result in a compilation error”
https://help.mikrotik.com/docs/display/ROS/Scripting#:~:text=Undefined%20variables%20will%20be%20marked%20as%20undefined%20and%20will%20result%20in%20a%20compilation%20error

Nope, just try the code.

I think I’ve found the answer in http://forum.mikrotik.com/t/a-few-undocumented-operators-that-are-kind-of-neat/163557/1

:set $X 10

will update or append an element named X in/to the array of parameters. For more details see that topic, among
others how to pass arguments by reference.