• v0.6.0 a9722e439b

    tklips v0.6.0 Stable

    michael released this 2026-11-10 16:56:03 +00:00 | 12 commits to master since this release

    tklips v0.6.0: a terser, more regular syntax — capture patterns, >> between a function's parameters and its body, fn, paths into objects, spreads of any expression, for and multi-branch if — and fewer fact built-ins. It breaks existing programs; the repository's tools/ holds a converter for each breaking change but one. The reference PDF documents the language as released.

    Breaking changes

    Run the converters in this order on .tk files, Markdown code blocks and test inputs; each lists on stderr what it leaves for review: tools/convert-captures.py, tools/quote-texts.py, tools/convert-fact-reads.py, tools/convert-func-bodies.py.

    • Functions separate their parameters from their body with >>. (func f a b body) becomes (func f a b >> body) and (lambda x body) becomes (lambda x >> body); a body is now any number of expressions, so a (block ...) body can be unwrapped. func or lambda without >> fails with func: missing >>, with two with duplicate >>; >> can no longer name a parameter. tools/convert-func-bodies.py rewrites programs, turning one-parameter lambdas into fn.
    • Patterns capture with >. In rules and fact-match, >name captures an entry, >.name captures the named entry .name, &name and &.name match a variable's value, and a bare value matches itself. A capture on a name already visible fails with variable <name> already taken instead of joining. The separator of rule and fact is >>: a rule written with > fails with rule: missing >>. tools/convert-captures.py rewrites programs.
    • Texts that are neither words nor operators must be quoted. 1e3, 12abc, ../x.tk, 10:30 or été written bare fail with text must be quoted: <atom>; write "../x.tk". The printer quotes them in turn. tools/quote-texts.py rewrites programs.
    • Facts are read and removed by id. fact-find-read, fact-match-read, fact-del-all and the pattern form of fact-del are gone: write (fact-fetch *(fact-find ...)), (fact-fetch *(fact-match ...)) and (fact-del *(fact-find ...)). (fact-del id...) returns how many facts it removed, not an id. tools/convert-fact-reads.py rewrites programs.
    • sort takes its comparator by name: (sort obj &cmp) becomes (sort obj (.cmp &cmp)). No converter.
    • Names can't contain dots, which now separate path segments: (set a.b 1) fails. No converter.
    • Printed texts escape line feeds, tabs and carriage returns as \n, \t and \r, so every printed value fits on one line; print, join and the writers of raw bytes are unchanged.

    Language

    • (fn x body): a lambda of one parameter and one body expression, without >>. Lambdas print as the call that made them, (fn x &x) or (lambda a b >> (join &a &b)).
    • Paths: &order.lines.0 reads into objects, a digit segment being a position and &k a computed key, &a.&k. Paths work as values, call heads ((&h.greet Ann)), spreads (*order.lines) and in patterns. (. obj key... (.strict 1)) fails on a missing key with .: missing key <k>, code unknown/key.
    • *(expr) spreads the value of any expression into a call, as *x spreads a variable: (max *(map &people (fn p &p.age))). A call evaluates its expression spreads first, left to right, then checks its arguments.
    • if takes any number of condition and branch pairs, then an optional else branch: (if (< &n 0) neg (= &n 0) zero pos).
    • (for (name source (.pos pos)) body...) loops over an object's items, or over 0 to n-1 for an integer n.
    • != compares as the negation of =.
    • Quoted texts accept the escapes \n, \t and \r.
    • sort takes (.reverse 1), which reverses the order while equal items keep theirs: (sort obj (.cmp) (.key) (.reverse 0)).

    Facts

    • (fact-fetch id...) gives the bodies of the facts of those ids, in their order, each with its .id; (fact-del id...) removes them and returns how many. Both check every id first, and take no id too, so an empty query spreads.

    Rules

    • Patterns match literal values and variables directly, (person (.name Ann) >.age), and those narrow the facts a rule tries as joins do.
    • A rule pattern's &name naming no visible capture or constant fails when the rule is defined, with rule: unbound variable <name>.

    JavaScript module

    • A lambda handed to JavaScript keeps its whole body when it comes back: several body expressions, and *(expr) spreads in it, which lost their mark before.

    Python module

    • The same holds for lambdas handed to Python.

    SHA-256

    d57f8c69360c992c854862a8dbdd437c5d91a60669357957ec2a2036ebdb7035  tklips-v0.6.0-linux-x86_64
    00ae448271f2cd5c2aead57751b97d761e67c5c0e112e8e9f62860db1a23e329  tklips-v0.6.0-reference.pdf
    017422909edbf31598c86932ed6f18f6310ba6a60c7d51ed69f95e393e4cf7a5  tklips-v0.6.0.mjs
    60cd8f8955543d26494d55502aeded034cd3fbc82eef892953f9800b5b5b5f72  tklips-v0.6.0.py
    
    Downloads