Skip to content

Keywords and Identifiers

Keywords

Keywords are reserved words in Harneet that have special meaning and cannot be used as identifiers (e.g., variable names, function names).

Reserved Keywords

  • var: Used for variable declaration.
  • function: Used for function declaration.
  • if, else: Used for conditional statements.
  • for: Used for loops.
  • switch, case, default: Used for switch statements.
  • import: Used to import modules.
  • return: Used to return values from functions.
  • and, or, not: Logical operators.
  • true, false: Boolean literals.
  • None: Represents the absence of a value.

Type Keywords

These keywords are used to specify data types.

  • int, int8, int16, int32, int64: Signed integer types.
  • uint, uint8, uint16, uint32, uint64, uintptr: Unsigned integer types.
  • float32, float64: Floating-point types.
  • string: String type.
  • bool: Boolean type.

Identifiers

Identifiers are names given to variables, functions, modules, and other program entities.

  • Rules:
    • Must start with a letter (a-z, A-Z) or an underscore (_).
    • Can contain letters, numbers (0-9), and underscores.
    • Case-sensitive (e.g., myVar and myvar are different).
  • Conventions: Follow consistent naming conventions for readability.