libcwal  Update of "th1ish"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.


Artifact ID: e3f8882b79250ddff4ee0da86ff27087fdb3731c
Page Name:th1ish
Date: 2016-02-16 11:40:52
Original User: stephan
Parent: 7d1f6212e783ec1608eac210ef71382842c6b4c7

ACHTUNG: on 201602016, th1ish was remove from the trunk, placed into the th1ish-R.I.P. branch, kept only for historical interest. It is holding cwal back from several improvements and is not worth the effort to maintain. s2 is its replacement (and the two are generally about 98% code-compatible when it comes to client-side cwal bindings).

th1ish - a cwal-based Scripting Language

[print "Hello, world!"]
$print 'Hello, world!'
print({Hello, world!})
$print <<<EOF
Hello, world!
EOF"Hello, world!\n")

th1ish is an experimental/toy scripting language initially (conceptually) based off of TH1, a lesser (and lesser-known) dialect of TCL. th1ish inherits much of TH1's syntax but is expression-centric (not command-centric), adds the richer types supported by cwal (which closely mimics JavaScript), and scoping/lifetime rules similar (but not identical) to C++. While there is still tweaking and experimentation to be done, th1ish is currently functional and ready to use in its original intended role: a simple-to-use platform with which to write scriptable test harnesses for C/C++ libraries and apps, and similar "light" scripting tasks. Binding client-side functionality to scripts is easy to do, including binding custom native types in such a way that th1ish can track their lifetimes and destroy them (using a client-provided finalizer) when the proper time comes.

th1ish is experimental and a toy, but can do far, far more than was originally envisioned/planned for it. (If nothing else, th1ish has proven to be an invaluable test-bed for the core cwal library.) th1ish is essentially feature-complete, but it is continually being tweaked.

See th1ish/th1ish*.c for the current code, th1ish/shell.c for the test app, and th1ish/unit/*.th1ish for various test scripts. th1ish is being documented in detail in a pair of public Google Documents:

  • Main docs
  • Loadable modules docs. sqlite3/MySQL db access, basic regex support, glob matching, SHA1 hashing, UUID generation, and CGI support all await in the loadable modules.

As of this writing (May 2014), those two docs weighs in at 265 kb of text, just over 100 pages, mostly about how to use it script-side, but also how to use it from C. The docs get updated as the code is written, so they always reflects the current trunk state or what will be checked into the trunk shortly.


Newest items at the top.

  • 201405: ongoing experimentation with the vacuum algorithm has yielded good results. th1ish now vacuums all scopes regularly except for the global one (where vacuuming breaks, apparently due to (as designed) non-script-visible values being cleaned up).
  • 20140407: th1ish is now being used to write CGI applications. This demo site is implemented entirely in th1ish.
  • 20130722: Added inherits keyword, which behaves almost the same as JavaScript's instanceof. Added -I flag to th1ish shell to dump the cwal string-interning table before cleaning up.
  • 20130720: Added toss keyword to replace use of return from inside catch blocks. Optimizations to how string memory is recycled cut the total memory allocation count anywhere from a few percent to 36%(!!!) in the test scripts.
  • 20130713: Added "popenish" loadable module, which opens a bi-directional read/write stream to a child process. Added "globish" module which provides two forms of glob-like string matching functions. Split loadable module docs into a separate document. Started work on a CGI plugin, which sets up the environment based on CGI-related data. The basics are in place, but still deciding on the exact semantics of its output model.
  • 20130712: Added api.json.parse(), which converts JSON strings to an Object or Array.
  • 20130711: Added "uuidish" loadable module (adds a uuid() function).
  • 20130710: added "sha1ish" loadable module (adds a sha1() function). Added handling of \uXXXX Unicode character escaping (with 2, 4, 6, or 8 hex digits) in quoted string literals (not identifiers, though that's now possible with a tiny bit of refactoring).
  • 20130706: now skips over #!shebang at the start of script to support making scripts executable via the Unix-conventional mechanism. Stack trace optimizations: (1) defer calculation of script location information until an exception is thrown and (2) no longer allocate stack entries on the heap (they're on the stack, of course!). Added bitwise negation operator. Added -e SCRIPT_CODE option to the shell app. Moved PCRE code into a loadable module. Still seeing the lurker in the Google Doc.
  • 20130705: Added 'dirent' plugin which adds an opendir(3) wrapper.
  • 20130704: added "heredocs" and an "auto-sweep" option (on by default) which cleans temporaries up every few expressions. Started this news list. Someone other than me (no idea who) has been hanging out in the Google Doc for the past two days.