Skip to content

Evaluation

Joakim edited this page Dec 19, 2021 · 8 revisions

kesh is line-oriented.

Lines

  • Code is evaluated line-by-line, top to bottom
  • Lines are separated by either newline or comma ,
  • There are two types of lines:
    1. Declaration lines
    2. Expression lines

Blocks

  • A block {} consists of lines
    • Declaration lines
    • Expression lines
  • A block has its own (lexical) scope
  • A block's value is the value of its last evaluated expression line
  • A block is an expression

Collections

  • A collection [] consists of lines
    • Declaration lines if object
    • Expression lines if other type
  • Collection is a reference type

Tuples

  • A tuple () consists of lines
    • Expression lines
  • Tuple is a reference type, ideally it would have value semantics

Functions

  • A function -> consists of parameters and a body
    • Its parameters is the unpacking of its argument, as either a tuple or a collection
      • The unpacked argument's values exist in the function scope
    • Its body is an expression, typically a block
  • Function is a reference type, being also a collection
    • A function is a callable collection
Clone this wiki locally