soma.cell

Quick rules

Quick rules, in the reference of the Soma programming language (soma 3.2.4). A block marked ✓ is a whole program that soma check accepts; the others are excerpts.

  • No semicolons. Newlines separate statements.

  • No function/def. Use on handler_name(params) { }.

  • No null. Use () for null/unit.

  • Lists: [1, 2, 3] and list(1, 2, 3) both work.

  • No {key: val}. Use map("key", val, "key2", val2).

  • No import. Use use lib::module.

  • No console.log. Use print(value).

  • No ===. Use ==.

  • Strings: "hello {name}" (interpolation with {}).

  • Multi-line strings: """...""" (backslashes are literal, quotes work inside; {x} IS interpolated — write {{ for a literal brace, so a template that a later render(tpl, "name", …) fills is written """hi {{name}}"""; a bare {name} with no such variable is a check error).

  • Integer division: 7 / 2 = 3.5 (auto-promotes to float when non-exact). Same in [native] handlers: 7 / 2 = 3.5, an exact quotient is an Int (BigInt-exact). Native code is statically typed, so a slot that can only hold an Int (an Int variable, an index) refuses a non-exact quotient with a runtime error — it never truncates. idiv(a, b) is the integer quotient on every backend (truncates toward zero, BigInt-exact).