-
tklips v0.6.0 Stable
released this
2026-11-10 16:56:03 +00:00 | 12 commits to master since this releasetklips 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,forand multi-branchif— and fewer fact built-ins. It breaks existing programs; the repository'stools/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
.tkfiles, 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.funcorlambdawithout>>fails withfunc: missing >>, with two withduplicate >>;>>can no longer name a parameter.tools/convert-func-bodies.pyrewrites programs, turning one-parameter lambdas intofn. - Patterns capture with
>. In rules andfact-match,>namecaptures an entry,>.namecaptures the named entry.name,&nameand&.namematch a variable's value, and a bare value matches itself. A capture on a name already visible fails withvariable <name> already takeninstead of joining. The separator ofruleandfactis>>: a rule written with>fails withrule: missing >>.tools/convert-captures.pyrewrites programs. - Texts that are neither words nor operators must be quoted.
1e3,12abc,../x.tk,10:30orétéwritten bare fail withtext must be quoted: <atom>; write"../x.tk". The printer quotes them in turn.tools/quote-texts.pyrewrites programs. - Facts are read and removed by id.
fact-find-read,fact-match-read,fact-del-alland the pattern form offact-delare 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.pyrewrites programs. sorttakes 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,\tand\r, so every printed value fits on one line;print,joinand 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.0reads into objects, a digit segment being a position and&ka 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>, codeunknown/key. *(expr)spreads the value of any expression into a call, as*xspreads a variable:(max *(map &people (fn p &p.age))). A call evaluates its expression spreads first, left to right, then checks its arguments.iftakes 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 over0ton-1for an integern.!=compares as the negation of=.- Quoted texts accept the escapes
\n,\tand\r. sorttakes(.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
&namenaming no visible capture or constant fails when the rule is defined, withrule: 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.pyDownloads
- Functions separate their parameters from their body with