params – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " <!-- (DIS)?CONTINUE Notes -->" to "")
m (Text replacement - "\[https?\:\/\/en\.wikipedia\.org\/wiki\/([^ ]+) (.+)\]" to "{{Wikipedia|$1|$2}}")
Line 10: Line 10:
<dt class="note">[[User:dreadedentity|dreadedentity]]</dt>
<dt class="note">[[User:dreadedentity|dreadedentity]]</dt>
<dd class="note">
<dd class="note">
[[params|Params]] really shines when used in [https://en.wikipedia.org/wiki/Recursion_(computer_science) recursive] functions.
[[params|Params]] really shines when used in {{Wikipedia|Recursion_(computer_science)|recursive}} functions.
<code>_myTestVar = 0;
<code>_myTestVar = 0;
[[systemChat]] [[str]] _myTestVar;
[[systemChat]] [[str]] _myTestVar;
Line 31: Line 31:
[[systemChat]] [[str]] _myTestVar;</code>
[[systemChat]] [[str]] _myTestVar;</code>
Outputs '''0 0'''<br>
Outputs '''0 0'''<br>
This happens because of the cascading nature of [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.
This happens because of the cascading nature of {{Wikipedia|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>
</dd>
</dl>
</dl>

Revision as of 15:56, 30 May 2021

If expectedDataTypes is excluded does the command use the default value as the expected data type? --SS (talk) 03:01, 17 July 2015 (CEST)

What? The command doesnt need to check data types if data type checking isnt used...Benargee (talk) 03:20, 17 July 2015 (CEST)
Thanks, that answers my question SS (talk) 13:34, 17 July 2015 (CEST)

Indirectly related

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 2 0 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.