-
tklips v0.3.0 Stable
released this
2026-10-23 16:50:32 +00:00 | 28 commits to master since this releasetklips v0.3.0 splits programs into sources with a standard library, handles errors as values, names built-in arguments, and gives rules test conditions and simpler patterns; the JavaScript module becomes asynchronous.
tklips-v0.3.0-reference.pdfdocuments the language as released.Breaking changes
- Capture patterns (
fact-match,fact-match-read, rule patterns) capture into bare names: write(person name (.age a))instead of(person &name (.age &a))..agealone is short for(.age age). - No literals in capture patterns: write
(person .sex (= &sex M))instead of(person (.sex M)). A number in a pattern now fails withinvalid variable name, and a text is a capture, so an old pattern with text literals matches more facts. - Strict functions: a user function or lambda without a rest parameter rejects arguments it has no parameter for, with
<f>: expected at most <n> arguments, got <m>and<f>: unknown named argument <name>. Add a rest parameter (*rest) to accept them. - New built-in names:
require,std,fail,try,catchandrecovery. A function of one of these names must be renamed. - Error messages and output: built-ins with parameter names report
<f>: missing argument <param>and<f>: expected at most <n> arguments, where they reportedexpected <n> arguments; an error raised inside a function is followed by its trace lines; the shadowing warning writescapture a shadows a variable, without&. - JavaScript API:
eval,call,apply,run,runProgram, and a session'sfeedandendreturn Promises:awaitthem.define,undefine,resetandsession()stay synchronous.
Language
(require source)imports a source once, in the scope where it is written, running its forms without echo; errors in it are located aslib.tk:2:1.- The standard library, written in tklips:
(require (std text))imports thetextlibrary, withtext-pad-left,text-pad-right,text-center,text-lines,text-wrap,text-capfirstandtext-capwords.(std text v0.3.0)names the copy of a given release. - Errors are values with a code (
type/not-text,unknown/function,arg/arity…), a message, data and a trace:(fail code message (.name value)…)raises one, its named arguments as data, and(fail e)raises a caught one again;(try expr… (catch e handler…) (catch (e code…) handler…))handles them, a code ending with/taking a whole family;(recovery value)in ablock, atryor a rule's actions ends the rest of the body withvalue, or a function's result on the error, when an error comes after it.
- An error nothing handles is written with the calls it went through:
in f, called at 3:1. - Built-ins take their arguments by position or by name:
(str-sub s (.end 3)),(reduce xs &+ (.init 10)),(partial map (.fn f)),(range 10 (.step 3)),(run (.limit 5)), and likewisestr-find,str-replace,str-repeat,slice,chunk,repeat,sort,filter,count,any,all,find,find-pos,group-by,partition,for-each,logandatan.str-subandslicestart at 0 by default.
Rules
(*test* expr…)holds when its expressions are true, with the captures of the conditions before it: to compare patterns,(rule bigger (p x) (q y) (*test* (> &x &y)) > …), as an alternative of*either*, or as what every match of*every*satisfies. It can be*persist*or*track*.- An error in a rule's test or action can be handled by
recoveryin its actions, which ends that firing and letsrungo on, or by atryaroundrun.
Command line
tklips main.tkruns a program file instead of stdin;tklips -i main.tkruns it, then opens the shell.--allow-urlletsrequirefetchhttp://andhttps://sources withcurl; files are read only inside the current directory.--stdlib <location>takes the standard library from another directory or URL; a release reads its own tagged copy by default.
JavaScript module
- A JavaScript function may return a Promise: the evaluation waits for it where the call stands, and the function may call back into its runtime meanwhile.
createRuntime({ resolve, read, stdlib })says whererequirefinds sources and where the standard library is; by default, paths are URLs, and Node reads files of the current directory.TklipsErrorhascode,data,traceandsource;tklipsFail(code, message, data)makes an error a JavaScript function can throw with a code.
SHA-256
0462340c083f37e115d12f74f00f7926468cafad99ad16a7adc6f48590a34249 tklips-v0.3.0-linux-x86_64 b9b12f85d113c9640f1bb6adf7a2caa17d91648c991ad3ce4dd695d925ae4674 tklips-v0.3.0.mjs 8da22559b355325af6ab84af4d20726346f51feb3b1845b275ec229a29068f15 tklips-v0.3.0-reference.pdfDownloads
- Capture patterns (