Jump to content
Sign in to follow this  
alef

Ignore assigning to nil

Recommended Posts

Please vote if you agree to avoid nil to be assigned.

nil can be assigned to any value, and later usage of this keyword will lead to problems. Mostly because it is used to cancel a variable at different scopes.

It's common to see around init lines with something like

nil = [1,2] execVM "script.sqf"

that is allowed but wrong, because if a mod or script will use later something like

_object setVariable ["myVar", nil]

to clean up some space, it will assign the handle of the thread. It will not be an error, until myVar will be dereferenced and used for something else.

The proposed feature is to simply ignore assignments to nil. A workaround is to use numbers, like

0 = [1,2] execVM "script.sqf"

Thank you,

alef

Share this post


Link to post
Share on other sites

if (not isnil "nil") then {nil = [] call {}}

:j:

It is a bit strange you can assign data to a ?data type? though.

Share this post


Link to post
Share on other sites

Some languages allow for that - it's a bad idea to override constants or magic variables.

But really - why not just declare a throw-away local variable and use that instead?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×