Hi, all,

the past two months have seen a complete rewrite of my own personal toy
scripting engine, largely inspired by limitations uncovered in it while
binding libfossil to it. As of today, partial libfossil bindings are in
place for the new language (the db abstraction layer is done), and there's
a demo script here:

http://fossil.wanderinghorse.net/repos/libfossil/index.cgi/finfo?name=s2/unit2/000-100-db.s2

Unless i get called off of vacation back to work next week, i "should" have
the remaining bits ported from the older binding by this time next week.
The older binding and this one use the same underlying scripting engine
(just different languages on top of it), so porting has been a
straightforward matter so far. The new scripting language is documented in
inordinate detail (>60 pages) here:

https://docs.google.com/document/d/1hvMoHSIz94dob6fCU6SLxle_s7YL6CrA_4aU12OWwWY/view

This one (called, rather uncreatively, "s2") is much cleaner than the first
one (th1ish), with a more robust core, proper operator precedence (with
over 30 overloadable operators), and its got (if i may say so)
bordering-on-outstanding memory usage:

https://docs.google.com/document/d/1hvMoHSIz94dob6fCU6SLxle_s7YL6CrA_4aU12OWwWY/view#heading=h.ucmv4mn8r0rw

Aaaaannnnddddd.... it's got an interactive shell mode:

[odroid@host:~/fossil/libfossil/s2]$ ./s2sh -v
s2 interactive shell. All commands run in the current scope. Use your
platform's EOF sequence on an empty line to exit. (Ctrl-D on Unix,
Ctrl-Z(?) on Windows.) Ctrl-C might work, too.

The 'g' object is at your service as a place to store things.
s2> var db = Fossil.Db.open(':memory:')
result: Db@0x85778[scope=#1@0xbeecc0d0 ref#=1] ==> Db@0x85778

s2> db.execMulti("create table t(a); insert into t(a) values(1),(2),(3);");
result: Db@0x85778[scope=#1@0xbeecc0d0 ref#=1] ==> Db@0x85778

s2> db.each({sql:'select * from t', callback:proc(){print(this)}, mode:0});
{"a": 1}
{"a": 2}
{"a": 3}
result: undefined@0x6f4c4[scope=#0@(nil) ref#=0] ==> undefined

s2> db.close()
result: undefined@0x6f4c4[scope=#0@(nil) ref#=0] ==> undefined

s2> db.close()
rc=105 (CWAL_RC_EXCEPTION)
EXCEPTION: exception@0x75370[scope=#1@0xbeecc0d0 ref#=0] ==> {
  "code": 118,
  "column": 8,
  "line": 1,
  "message": "'this' is not (or is no longer) a Db instance.",
  "script": "shell input",
  "stackTrace": [{
      "column": 8,
      "line": 1,
      "script": "shell input"
    }]
}
s2>



Happy Fossiling!

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to