The Þog of 2022-06-04 — Fake S-Expression Systems Language

sina toki e toki pona la, o lukin e ni!

Lisp and Scheme weren't designed for writing bare-metal programs on the type of computers we have today. Disassembled WebAssembly text is sort of close, but what would the point be to writing platform-specific assembly with parentheses everywhere?

Let's ruin Lisp by turning it into Worse C. Thankfully, this is only theoretical, so it won't cause harm by having programmers attempt to actually use this.

Informal syntax and grammar

Builtins

Examples

"Hello world!"

(fn.export (main.)
  (trace "Hello world!"))

Array and single characters

(fn.export (main.)
  (let (hello.[]u32 'h 'e 'l 'l 'o))
  (trace hello))

Calculate the magnitude of a 3-dimensional vector

(fn (vec3-length.real x.real y.real z.real)
  (ret (sqrt (+ (* x x) (* y y) (* z z))))

(fn.export (main.)
  (trace (vec3-length 0.0 0.5 1.0))) ; -> ~1.118

Calculate the length of a C-style NUL terminated string

(fn (my-strlen.uint str.&u8)
  (let (i.uint 0))
  (while (^ str i) (: i (+ i 1)))
  (ret count))

(fn.export (main.)
  (trace (my-strlen "How long is this?"))) ; -> 17