Skip to content

Latest commit

 

History

History
107 lines (96 loc) · 3.17 KB

scheme.md

File metadata and controls

107 lines (96 loc) · 3.17 KB

uFork LISP/Scheme Dialect

A LISP/Scheme dialect is implemented as a surface-syntax for uFork programs. A compiler (written in JavaScript) generates loadable IR just like ASM does.

Since this dialect is focused on expressing actor behaviors, it is a mostly-pure functional expression language. Most data-structures (including pairs) are immutable, and mutation features (e.g.: set!) are not supported. The language is extended with actor primitives. It is expected that mutation generally will be confined to the state of actors, managed with BECOME.

Literal Values

  • #? — undefined value
  • #nil — empty list, abbreviated ()
  • #f — boolean false
  • #t — boolean true
  • #unit — inert result
  • #literal_t — type of literal values
  • #type_t — type of types
  • #fixnum_t — type of fixnums (31-bit signed integers)
  • #actor_t — type of actor reference/capabilities
  • #instr_t — type of machine instructions
  • #pair_t — type of pairs (cons cells)
  • #dict_t — type of dictionary entries
  • fixnums (31-bit signed integers)

Built-In Facilities

  • (import <prefix> <URL>)
  • (define <symbol> <expr>)
  • (quote <expr>) — abbreviated '<expr>
  • (lambda <formal> . <body>)
  • (let ((<var> <val>) . <bindings>) . <body>)
  • (seq . <body>)
  • (list . values)
  • (cons head tail)
  • (car pair)
  • (cdr pair)
  • (cadr pair)
  • (caar pair)
  • (cdar pair)
  • (cddr pair)
  • (caddr pair)
  • (cadar pair)
  • (cdddr pair)
  • (cadddr pair)
  • (eq? value value)
  • (null? value)
  • (pair? value)
  • (boolean? value)
  • (number? value)
  • (actor? value)
  • (symbol? value)
  • (procedure? value)
  • (behavior? value)
  • (if <test> <t_expr> <f_expr>)
  • (cond (<test> . <body>) . <clauses>)
  • (and . <exprs>)
  • (or . <exprs>)
  • (not bool)
  • (+ number number)
  • (- number number)
  • (* number number)
  • (< number number)
  • (<= number number)
  • (= number number)
  • (>= number number)
  • (> number number)
  • (export . <symbols>)

Planned Facilities

  • (nth index pair)
  • (equal? value value)
  • (append . lists)
  • (length list)
  • (filter pred list)
  • (reduce binop zero list)
  • (foldl binop zero list)
  • (foldr binop zero list)
  • (map proc . lists)
  • (reverse list)
  • (letrec ((<var> <val>) . <bindings>) . <body>)
  • (current-env)
  • (print . values)

Meta-Actor Facilities

  • (CREATE behavior)
  • (SEND actor message)
  • (BECOME behavior)
  • SELF
  • (BEH <formal> . <body>)
  • (CALL actor args)
  • (DEVICE id)

Possible Future Features

  • (par . <exprs>)
  • (zip formal value env)
  • (gensym)
  • a-print