-
tklips v0.7.0 Stable
released this
2026-11-16 21:35:37 +00:00 | 5 commits to master since this releasetklips v0.7.0: programs written as indented lines, with
:to nest and|to pipe a value through calls, and one way to make a short function,fnwith holes, in place oflambda. It breaks existing programs; the repository'stools/holds a converter for the function and pipe changes. The reference PDF documents the language as released.Breaking changes
Run
tools/convert-pipe.py, thentools/convert-fn.py, on.tkfiles, Markdown code blocks and test inputs; each lists on stderr what it leaves for review.- Several atoms on a top-level line make a call.
42 abc _reads as(42 abc _), and1 (print hi) 2as(1 (print hi) 2). Put each form on its own line, or start the line with a list: a line starting with(still holds several forms. Code made only of parenthesized forms reads as before. A line indented under a list line fails withunexpected indentation, so a continuation line indented under a parenthesized form must be inside its parentheses. No converter. lambdais gone.(lambda a b >> body)becomes(func _ a b >> body), an anonymous function, which prints and is namedfuncin errors.fntakes one body and its parameters are holes.(fn x (* &x 2))becomes(fn (* @ 2)):@or@0is the first argument,@1the second, with paths (@.age) and spreads (*@).tools/convert-fn.pyrewriteslambdaand the oldfn, turning anfnit can't express with holes into(func _ x >> body).funcreturns the function it defines,&name, instead of_.pipepipes a value instead of composing functions.(pipe f g h)becomes(compose h g f);pipeis now a special form without a function value. A bare|is an operator, no longer a text: write"|".tools/convert-pipe.pyrewrites both.- Piped shell input and sessions wait for the end of a form.
tklips -ifed by a pipe, and a JavaScript or Python session'sfeed, evaluate a top-level form at the next blank line or line with no indentation, or at the end of input. The continuation prompt is...>, padded to line up withtklips>.
Language
-
Lines and indentation. Outside parentheses, a line is a call of its items, then of the lines indented under it; a line holding one atom is that atom; a blank line ends the form, a comment line doesn't. Inside parentheses, line feeds and indentation are whitespace as before. New syntax errors:
unexpected indentation,inconsistent indentationandtab in indentation.func classify age >> if (>= &age 18) adult minor -
:nests the rest of its line or list as one item:print : str-upper : join a bis(print (str-upper (join a b))). -
|pipes a value through stages, each a call that takes it as its first argument, or wherever@stands:&people | map (fn @.age) | max *@,10 | - 100 @. A line starting with|under another adds a stage.@is evaluated where a stage first uses it, at most once. A stage without@fails withpipe: no @ in <stage>, and@outside a stage or anfnwith@ outside a pipe or fn. -
fncaptures the variables its body mentions, by value, when it is made, and prints them:(fn (.n 3) (+ &n @)). Its named arguments are explicit captures. It takes as many arguments as its highest hole plus one, and ignores extra ones. -
(func _ ...)makes an anonymous function, with rest and optional parameters. -
The atoms of a block comment are no longer checked:
(# version 1.2.3, at 10:30)is a valid comment. -
forbinding a constant's name fails withfor: cannot shadow constant <name>, assetdoes; invalid variable and indirect names have the codearg/invalid-name.
Facts
- In
fact-matchpatterns,>fbefore the relation captures the fact's id and&fmatches only the fact of that id:(fact-match >f person (.name Bob)),(fact-match &g person). Giving the id twice fails withduplicate name .id.
Rules
- Rule patterns take the same id heads, markers included:
(rule seen (>f person >.name) (*none* (seen &f)) >> (fact-add seen &f)).
Interactive shell
- On a terminal, Enter runs the form typed so far; Alt+Enter and Ctrl+J continue it on a new line, pre-indented. A multi-line paste joins the form and runs on Enter.
JavaScript module
session.submit(text)feeds lines and completes the form that waits, as Enter does.- The web REPL takes Shift+Enter, Ctrl+Enter and Alt+Enter for a new line, and submits its input on Enter.
Python module
session.submit(text), as in the JavaScript module.
SHA-256
d0cddc7c456ff223494c55afd8f3df46e6c6aba37f34e96bf184b0d5561b319a tklips-v0.7.0-linux-x86_64 dd28d202a9c817e1c4d7fa43275b4e343aca9fce7c95cd1cd28c9623ed7ce0c1 tklips-v0.7.0-reference.pdf 9e14db58243e9244fe513917eb0e3b552222c16809e4336f06fddc5e12c279a3 tklips-v0.7.0.mjs 00525ae9a4dfc2fea360d945352817d27adaa4a5af664b944abc6570ab989e68 tklips-v0.7.0.pyDownloads
- Several atoms on a top-level line make a call.