• v0.7.0 259f7791ab

    tklips v0.7.0 Stable

    michael released this 2026-11-16 21:35:37 +00:00 | 5 commits to master since this release

    tklips 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, fn with holes, in place of lambda. It breaks existing programs; the repository's tools/ holds a converter for the function and pipe changes. The reference PDF documents the language as released.

    Breaking changes

    Run tools/convert-pipe.py, then tools/convert-fn.py, on .tk files, 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 _), and 1 (print hi) 2 as (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 with unexpected indentation, so a continuation line indented under a parenthesized form must be inside its parentheses. No converter.
    • lambda is gone. (lambda a b >> body) becomes (func _ a b >> body), an anonymous function, which prints and is named func in errors.
    • fn takes one body and its parameters are holes. (fn x (* &x 2)) becomes (fn (* @ 2)): @ or @0 is the first argument, @1 the second, with paths (@.age) and spreads (*@). tools/convert-fn.py rewrites lambda and the old fn, turning an fn it can't express with holes into (func _ x >> body).
    • func returns the function it defines, &name, instead of _.
    • pipe pipes a value instead of composing functions. (pipe f g h) becomes (compose h g f); pipe is now a special form without a function value. A bare | is an operator, no longer a text: write "|". tools/convert-pipe.py rewrites both.
    • Piped shell input and sessions wait for the end of a form. tklips -i fed by a pipe, and a JavaScript or Python session's feed, 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 with tklips> .

    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 indentation and tab 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 b is (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 with pipe: no @ in <stage>, and @ outside a stage or an fn with @ outside a pipe or fn.

    • fn captures 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.

    • for binding a constant's name fails with for: cannot shadow constant <name>, as set does; invalid variable and indirect names have the code arg/invalid-name.

    Facts

    • In fact-match patterns, >f before the relation captures the fact's id and &f matches only the fact of that id: (fact-match >f person (.name Bob)), (fact-match &g person). Giving the id twice fails with duplicate 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.py
    
    Downloads