-
tklips v0.2.0 Stable
released this
2026-10-22 19:24:05 +00:00 | 39 commits to master since this releasetklips v0.2.0 grows the language with text, number and collection built-ins, gives rules an explicit firing order and fact tracking, and ships the engine as a JavaScript module. The language reference for this version is attached as a PDF.
Breaking changes
%is nowrem, with the same behavior:(% 7 3)becomes(rem 7 3). The newmodis the floored modulo, with the sign of the divisor.attrsreturns an object's attributes as an object,(obj (.x 1)), instead of a list of(obj (.name x) (.value 1)). Usekeyvaluesfor a list of(obj name value)pairs, andkeysorvaluesfor the names or values alone.fact-setandfact-updateare removed, and so is the keyed form offact-add((fact-add rel key... > update...)). Write(fact-change id update...)for(fact-set id > ...)and(fact-update id > ...), and(fact rel pattern... > update...)for(fact-set rel pattern... > ...).- A call whose head is
&namenow calls whatnameholds:(&f 1)used to fail withunknown function: &f. - Many new built-in names (listed below) can no longer be defined with
func. A&namereference to one of them where no variable of that name is visible, such as&lastor&min, now gives the built-in's function value instead of failing withunbound variable. Variables of those names keep working where they are visible.
Language
- Texts:
str-len,str-sub,str-find,str-starts,str-ends,str-split(at a separator, into characters or at whitespace, with.max),str-join,str-upper,str-lower,str-trim,str-ltrim,str-rtrim,str-replace,str-repeat,str<,str>,str<=,str>=andstr-cmp. They take texts only and count characters, not bytes.strturns any value into a text, andnumreads a number back, giving_when the text isn't one. - Kinds:
kindnames any value's kind (int,float,str,none,list,obj,func), andis-int,is-float,is-number,is-str,is-none,is-list,is-objandis-functest for one. - Numbers:
floor,ceil,roundandtruncreturn integers;abs,min,max,mod,cmp;pow, exact on integers;sqrt,exp,log(with an optional base),sin,cos,tan,asin,acos,atan(with atan2),(pi)and(e). A result that isn't a real number fails withnot a real number.nearscompares two numbers to 10 decimal places, or.digits. - Collections, on an object's items, keeping their positions:
filter(without a predicate, it removes the holes),reverse,slice,concat,flatten,partition,zip,chunkandnumbered. Giving new lists:sort(stable, with a comparator or a.key),unique,group-by,range(integers or floats, with.inclusive) andrepeat. Giving one value:reduce,find,find-pos,any,all,count,firstandlast. - Attributes:
keys,values,keyvalues,from-keyvaluesandmerge.itemsandattrssplit an object in two, and(obj *i *a)rebuilds it. (. obj key...)follows a path of keys, giving_as soon as an entry is missing or a value on the way isn't an object.- Functions:
call,map,compose,pipeandpartial. Wherever a function is expected, its name works too, and(&f args...)calls the function a variable holds. pprintwrites a value in an indented form, one entry per line.
Facts
fact-addalways adds a fact.fact-changechanges the fact with a given id.factis the upsert by pattern: with> update...it updates the one match or adds the pattern and updates it; without, it adds the pattern only when nothing matches, and returns the id either way.
Rules
(*after* name...)and(*before* name...), written among a rule's conditions, put it after or before other rules whenever both have activations pending.*track*on a condition, or(*track*)for every condition of a rule, makes a firing own the facts it creates: once a tracked condition stops holding, the nextrunremoves them, as CLIPS does withlogical.
Interactive shell
- A result holding nested objects prints one entry per line, indented. Batch mode keeps every result on one line.
JavaScript module
- New:
tklips-v0.2.0.mjs, one ES module with the engine compiled to WebAssembly, for Node 18+ and browsers.createRuntime()gives independent runtimes witheval,call,apply,run,reset,runProgramand interactivesessions. Values convert both ways, and errors throw aTklipsError. definemakes JavaScript functions callable from tklips as built-ins, with named arguments if asked for;undefineremoves one.
SHA-256
4e4619692df2f7ff1fcfaffacde23a17ce8a1f18e05c96804139ce22423a305d tklips-v0.2.0-linux-x86_64 d184f6030d5fbcb2b480dd61f492fa75ccbbb5a73230a93cef8309b152c9fb68 tklips-v0.2.0-reference.pdf 97140e6b455dcf98538394a72ef68c95a271ac30a8604f3e44b675ab1082fe57 tklips-v0.2.0.mjsDownloads