params – Talk
Jump to navigation
Jump to search
No edit summary |
Lou Montana (talk | contribs) m (Text replacement - "\{\{ *Wikipedia *\| *([-()a-zA-Z0-9_#':%\/\\]+) *\| *([-()a-zA-Z0-9_#':%\/\\ ]+) *\}\}" to "{{Link|https://en.wikipedia.org/wiki/$1|$2}}") |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
::::Thanks, that answers my question [[User:SilentSpike|SS]] ([[User talk:SilentSpike|talk]]) 13:34, 17 July 2015 (CEST) | ::::Thanks, that answers my question [[User:SilentSpike|SS]] ([[User talk:SilentSpike|talk]]) 13:34, 17 July 2015 (CEST) | ||
== Indirectly related == | |||
<dl class="command_description"> | |||
<dt></dt> | |||
<dd class="notedate">Posted on April 3, 2019 - 00:39 (UTC)</dd> | |||
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt> | |||
<dd class="note"> | |||
[[params|Params]] really shines when used in {{Link|https://en.wikipedia.org/wiki/Recursion_(computer_science)|recursive}} functions. | |||
<code style="display: block">_myTestVar = 0; | |||
[[systemChat]] [[str]] _myTestVar; | |||
_myTestVar [[call]] { | |||
_myTestVar = [[Magic Variables|_this]] + 1; | |||
_myTestVar [[call]] { | |||
_myTestVar = [[Magic Variables|_this]] + 1; | |||
} | |||
}; | |||
[[systemChat]] [[str]] _myTestVar;</code> | |||
Outputs '''0 2''' | |||
<code style="display: block">0 [[params]] ["_myTestVar"]; | |||
[[systemChat]] [[str]] _myTestVar; | |||
_myTestVar [[call]] { | |||
([[Magic Variables|_this]] + 1) [[params]] ["_myTestVar"]; | |||
_myTestVar [[call]] { | |||
([[Magic Variables|_this]] + 1) [[params]] ["_myTestVar"]; | |||
} | |||
}; | |||
[[systemChat]] [[str]] _myTestVar;</code> | |||
Outputs '''0 0'''<br> | |||
This happens because of the cascading nature of {{Link|https://en.wikipedia.org/wiki/Recursion_(computer_science)|recursion}}, inner-level functions create variables of the same name, thus they are of the same name and a lower scope, therefore the engine treats them as though they are the same variable. [[params|Params]] gets around this, most likely, by creating a new, unique application-level variable under the hood, despite being of the same name. | |||
</dd> | |||
</dl> |
Latest revision as of 00:48, 24 February 2023
If expectedDataTypes is excluded does the command use the default value as the expected data type? --SS (talk) 03:01, 17 July 2015 (CEST)
- Posted on April 3, 2019 - 00:39 (UTC)
- DreadedEntity
-
Params really shines when used in recursive functions.
_myTestVar = 0; systemChat str _myTestVar; _myTestVar call { _myTestVar = _this + 1; _myTestVar call { _myTestVar = _this + 1; } }; systemChat str _myTestVar;
Outputs 0 20 params ["_myTestVar"]; systemChat str _myTestVar; _myTestVar call { (_this + 1) params ["_myTestVar"]; _myTestVar call { (_this + 1) params ["_myTestVar"]; } }; systemChat str _myTestVar;
Outputs 0 0
This happens because of the cascading nature of recursion, inner-level functions create variables of the same name, thus they are of the same name and a lower scope, therefore the engine treats them as though they are the same variable. Params gets around this, most likely, by creating a new, unique application-level variable under the hood, despite being of the same name.