S indicates the current scope.
Some terminologies(as well as interfaces provided in NameResolution.jl) :
LHS: left-hide-sideRHS: right-hide-sidepseudo scope: a scope but does not introduce free variables in its parent scope. I don't know how to call it actually,pseudo scopeis a tentative name.LOCAL: to mark a symbol as local, instead of resolving it automaticallyGLOBAL: to mark a symbol as global, instead of resolving it automatically
for i = I, j in J
body
endi is LHS in in S/for1, I is RHS in S.
j is LHS in S/for1/for2, J is RHS in S/for1.
body is RHS in S/for1/for2.
$f = aIf $f is a function calling expression, it's treated as function $f; a end . See [Function Definition](#Function Definition).
Otherwise, all symbols(except heads of expressions) of $f are LHS in S, a is RHS in S.
function f(x::A{T}=default_value) where T
body
endfis LHS inS(however the function name should be marked for further analysis, e.g., self recursions).
There's a pseudo scope S/mk-type-params,
Tinwhere Tis LHS inS/mk-type-params.
The requirement of a symbol in argument type annotations is from the scope S/mk-type-params.
Say,
Tinf(x::A{T}=value)is RHS inS/mk-type-params, andAis RHS inS/mk-type-params(though we knowAis fromS, pseudo scope doesn't result in free variables).
The function execution has the scope S/mk-type-params/inner and,
xis LHS inS/mk-type-params/inner,default_valueis RHS inS/mk-type-params/inner,bodyis RHS inS/mk-type-params/inner
Except for
Expr(:function, ::Symbol, Expr(:block, _...))is a declaration
let a = b
c
endS/let is a pseudo scope.
bis RHS inSais LHS inS/letcis RHS inS/let