Skip to content

Evaluation

Joakim edited this page Dec 11, 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's value is the value of its last evaluated expression line
  • A block is itself an expression

Collections

  • A collection [] consists of lines
    • Declaration lines in objects
    • Expression lines in other types
  • 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 -> is a callable collection
  • 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 are available to the function body's scope
  • Its body is an expression, typically a block
  • Function is a reference type

Not exactly BNF:

block      > line (> declaration) > expression (> …)
collection > line (> declaration) > expression (> …)
tuple      > line > expression (> …)
function   > expression (> …)
Clone this wiki locally