Variables behaviour in 3.10

What’s the correct use of variables in 3.x? I am missing some docs and i can’t get it to work, even the given examples (ddns on wiki).

An undefined variable should have a type of nil, but it has a type of “nothing”!
An unset variable has a type of “nil”, but mind quotes because, as opposed to all examples, it requires the word “nil” to be quoted or it just won’t work.

Try this script, but beware it will work only the first time:

:global nonExist

# Round 1. Variable should not exist

:log info ( "Round 1. Non existing variable has type of: " . [:typeof $nonExist ] )

:if ( [ :typeof $nonExist ] = nil ) do={ 
   :log info "Nil type"
}

:if ( [:typeof $nonExist ] = nothing ) do={
   :log info "Nothing type"
}

:if ( [:typeof $nonExist ] = "nil" ) do={
   :log info "Quoted Nil type"
}

:if ( [:typeof $nonExist ] = "nothing" ) do={
   :log info "Quoted Nothing type"
}

# Round 2. Clear variable. I assume this is the way to do it.
:set nonExist

:log info ( "Round 1. Cleared variable has type of: " . [:typeof $nonExist ] )

:if ( [ :typeof $nonExist ] = nil ) do={ 
   :log info "Nil type"
}

:if ( [:typeof $nonExist ] = nothing ) do={
   :log info "Nothing type"
}

:if ( [:typeof $nonExist ] = "nil" ) do={
   :log info "Quoted Nil type"
}

:if ( [:typeof $nonExist ] = "nothing" ) do={
   :log info "Quoted Nothing type"
}

Expected result:

Round 1. Non existing variable has a type of: nil
Nil type
Quoted Nil type
Round 2. Cleared variable has a type of: nil
Nil type
Quoted Nil type

Actual result:

Round 1. Non existing variable has a type of: nothing
Quoted Nothing type
Round 2. Cleared variable has a type of: nil
Quoted Nil type

I too am having hassles with the :nothing operator in V3 here:

{ :local foo
 :local bar
 
 :if ($foo = [:nothing] ) do={ :set foo foo }
 :put $foo
}

This just wont see the newly created variable as nothing (empty/unset) as in 2.9 so it wont set foo. foo will remain an empty variable.