Skip to content

1 : Variables

Paulyn edited this page Nov 28, 2025 · 1 revision

1. Variables

LAT supports two main variable types:

  • Global variables

  • Local variables (nat)


1.1 Global Variables

A global variable is created simply by assigning to a name:

x = 10 x = x + 5

Properties

  • Exists for the entire program duration

  • Can be accessed by any function

  • Can be overwritten without restrictions

  • Does not require a type annotation

Behavior Example

x = 2

call add() x = x +

10 done

add()

print(x) -- prints 12

1.2 Local Variables (nat)

Local variables must use the nat keyword:

nat score = 0 nat health = 100

Properties

  • Exists only within the current block

  • Cannot be accessed outside the function

  • Must be initialized at declaration

  • Shadowing globals with the same name is allowed

Example: Shadowing

x = 50

call test() nat x =

5 print(x) -- prints 5 (local) done

test()

print(x) -- prints 50 (global)

Clone this wiki locally