https://til-lang.github.io/til/
Til is a command language written in D whose syntax is inspired by Tcl. It aims to be:
The title made me think of Threaded Interpretive Languages, meaning Forth and its relatives, which have nothing to do with this language.
proc list_joiner (separator list) { length $list | as n set counter 0 list | as receiving range $list | foreach item { set counter $($counter + 1) push $receiving $item if $($counter < $n) { push $receiving $separator } } set s "" range $receiving | foreach item { set s "$s$item" } return $s } scope "test list_joiner" { set target_list (a b c d e) set separator ", " # Compare our function's result with the built-in `join` method: assert $([list_joiner $separator $target_list] == [join $separator $target_list]) }
In the example we can see that:
With this package you can create Tcl interpreters and run commands in them:
scope "load Tk, just because" { tcl | autoclose | as t run $t {{ package require Tk }} print "Tk loaded!" } scope "interpret a String as Tcl code" { tcl | autoclose | as t run $t "set x 123" print "x in Tcl is " <$t x> assert $(<$t x> == "123") } scope "interpret Til code as Tcl" { tcl | autoclose | as t run $t {{ set x 123 puts "x (from inside Tcl) is $x" }} assert $(<$t x> == "123") } scope "get values from Tcl" { tcl | autoclose | as t run $t "set x 321" set value <$t x> assert $($value == "321") print "x in Tcl is $value" }
Notice that it implements extraction of values from the interpreter (that is: getting the value from a variable) with proper syntax (<$interpreter $variable_name>).