← home · docs · guide · std

spec — complete reference, no source needed

This page is the contract. One page to work with SB — no need to open src/*.c. Written for humans, structured so AIs can also rely on it.

TL;DR
SB                     # first line of every file
set x to 1.           # every statement ends with .
define f with a as give back a. end.
pls bring maths.       # import std/lib
say f with 2.          # → 2  (also f(2))

0contents

1 lexical — what exists 2 types 3 statements & blocks 4 expressions & operators 5 scoping & mutability — the law 6 builtins 7 ketiwe (X11 pixel UI) 8 shimgui (GTK) 9 modules — pls bring 10 errors, try/catch 11 CLI & build 12 gotchas for AIs

1lexical — what exists

Every sentence ends with .. No ;. Keywords are English words:

SB  set to give back define with as and plus minus times divided by divided evenly by mod
is is not is greater than is less than not or and
if then otherwise otherwise if else elif end
while count from to loop through break continue
try catch raise match with _
say ask pls bring
# symbols that also exist: < > <= >= = == !=  ( ) [ ] ,  "  ${}
What does NOT exist: is greater than or equal to, is less than or equal to, substr, floor/ceil, ketiwe_delay, ketiwe_key with args. Use symbols <= >=, length, divided evenly by, sleep_ms, ketiwe_key_press (no args).

2types

typeliteralnotes
number3 2.5float (double) everywhere. int division via divided evenly by
string"hi ${x}"${} interpolation. no multiline needed
listlist with 1 and 2 and 3 list with (empty)ordered. length with, item with i and L, L[i], add_to/remove_from
mapmap("k", 1)m["k"] / m["k"] = v

3statements & blocks

SB
set x to 1.
if x is 1 then say "yes". end          # one-liner then auto-closes at EOL
if x is 1 then
  say "big".
otherwise if x is 0 then say "zero".
otherwise say "no".   # also else / elif
end
while x is less than 3 then set x to x plus 1. end
count i from 0 to 3 then say i. end
define add with a and b as give back a plus b. end.
define tick with as say "hi". end.  # zero-arg needs with

4expressions & operators

Precedence trap: item with 0 and X plus 1 parses as item with 0 and (X plus 1) → crash. Hoist: set t to item with 0 and X. then t plus 1.

5scoping & mutability — the law

This is the #1 source of bugs for AIs.

# globals
set HP to list with 100.   # single-element list = mutable scalar

define heal with n as
  set x to item with 0 and HP.   # read
  set x to x plus n.
  set HP[0] to x.              # write-through ✓
  set HP to x.                 # ← WRONG: creates function-local, global unchanged
end.

6builtins

groupnames
mathabs sin cos tan sqrt log only via std/maths; core has divided evenly by trick
stringslength with s upper/lower/trim/split/join/contains/replace/find/reverse/to_string/to_number/type_of
listslength with L item with i and L add_to with L and v remove_from with L and i L[i]
timetime_ms with sleep_ms with n (not ketiwe_delay)
iosay ask

Keys: there is no substr — use length + concatenation. Font for ketiwe_text is fixed (~8px/char mono, ~13px tall, baseline y).

7ketiwe (X11 pixel UI) — no GTK

ketiwe_window with "Title" and 800 and 600.
ketiwe_clear with "#1a1a2e".
ketiwe_rect with x and y and w and h and "#fff".
ketiwe_rect_outline with x and y and w and h and "#fff".
ketiwe_circle with cx and cy and r and "#fff".
ketiwe_line with x1 and y1 and x2 and y2 and "#fff".
ketiwe_text with x and y and "hi".  # only x y text, color arg is ignored
ketiwe_button with x and y and w and h and label. # returns 1 on click
ketiwe_poll with. ketiwe_flip with.
ketiwe_key_press with.   # no args, one-shot X11 keysym int, cleared on read. 119 w 97 a 115 s 100 d 32 space 49-52 1-4 113 q 65361-65364 arrows. Esc also closes window via ketiwe_poll.
ketiwe_mouse_x/y/down with.  # held state, updated on poll. No key-held API → design one-shot steps (X autorepeat helps) + mouse fire.
time_ms / sleep_ms with   # frame pacing; ketiwe_text uses XDrawString baseline

8shimgui (GTK)

shimgui_window with "App" and 460 and 320.
shimgui_label with "Hello".
shimgui_entry with "Name...".
shimgui_button with "Click".
shimgui_run with.
say shimgui_entry_text with 0.
say shimgui_last_click with.

9modules — pls bring

pls bring NAME. resolves <searchpath>/NAME.sb then <searchpath>/NAME/main.sb then the importing file's own directory (added to search path on load). Convention: one dir per lib with main.sb umbrella. Install via symlink/dir in ~/.shimbabomb/libraries/NAME/.

Reserved words you cannot use as params: count (loop), likely others — rename to cols/cnt.

10errors, try/catch

try
  set y to 10 minus "oops".
catch e
  say e. say e_info["line"]. say e_info["trace"]. say err_name with e_info["code"].
end

11CLI & build

cmdnotes
sb file.sbrun
sb -iREPL. sb --parse-only file.sb checks syntax
sb build file.sbcompile to standalone native binary
sb pack deb|rpm|exeinstallers
sb fmt / test / doc / lspformat, test, docs, LSP

12checklist — copy this

Tip: this spec + site/docs/ + std/*.sb are the reference. Everything here is verified against the interpreter — you don't need .c.