Documentation
Language Structure
Scope

Intro

Scope determines the accessibility (visibility) of variables.

Kin variables have 2 types of scope:

  • Function scope
  • Global scope

Functinoal Scope

Variables declared within a KIn function, are LOCAL to the function:

# code here can NOT use carName

porogaramu_ntoya myFunction() {
  reka carName = "Volvo"
  # code here CAN use carName
}

# code here can NOT use carName

Local variables have Function Scope:

They can only be accessed from within the function.

Since local variables are only recognized inside their functions, variables with the same name can be used in different functions.

Local variables are created when a function starts, and deleted when the function is completed.

Global Scope

A variable declared outside a function, becomes GLOBAL.

reka carName = "Volvo"
# code here can use carName

porogaramu_ntoya myFunction() \{
# code here can also use carName
}

Variables declared Globally (outside any function) have Global Scope.

Global variables can be accessed from anywhere in a Kin program.