libcwal  Hex Artifact Content

Artifact aea50bbc93a9dc03400b5155d261f1f8705d382e:

Wiki page [s2] by stephan 2017-12-01 09:57:33.
0000: 44 20 32 30 31 37 2d 31 32 2d 30 31 54 30 39 3a  D 2017-12-01T09:
0010: 35 37 3a 33 33 2e 34 38 30 0a 4c 20 73 32 0a 50  57:33.480.L s2.P
0020: 20 65 33 35 30 37 31 65 66 38 61 38 32 31 65 38   e35071ef8a821e8
0030: 62 65 34 65 35 31 66 65 62 35 36 35 37 65 34 65  be4e51feb5657e4e
0040: 32 31 33 61 66 62 31 63 65 0a 55 20 73 74 65 70  213afb1ce.U step
0050: 68 61 6e 0a 57 20 36 34 32 37 0a 3c 68 31 3e 73  han.W 6427.<h1>s
0060: 32 3a 20 63 77 61 6c 27 73 20 32 6e 64 20 73 63  2: cwal's 2nd sc
0070: 72 69 70 74 69 6e 67 20 6c 61 6e 67 75 61 67 65  ripting language
0080: 3c 2f 68 31 3e 0d 0a 0d 0a 28 41 63 74 75 61 6c  </h1>....(Actual
0090: 6c 79 2c 20 69 74 27 73 20 74 68 65 20 33 72 64  ly, it's the 3rd
00a0: 2c 20 62 75 74 20 28 41 29 20 74 68 65 20 66 69  , but (A) the fi
00b0: 72 73 74 20 6f 6e 65 20 77 61 73 20 61 20 74 68  rst one was a th
00c0: 72 6f 77 61 77 61 79 20 70 72 6f 74 6f 74 79 70  rowaway prototyp
00d0: 65 20 61 6e 64 20 28 42 29 20 53 33 20 69 73 20  e and (B) S3 is 
00e0: 74 68 65 20 6e 61 6d 65 20 6f 66 20 61 20 63 68  the name of a ch
00f0: 69 70 20 6d 61 6e 75 66 61 63 74 75 72 65 72 2e  ip manufacturer.
0100: 29 0d 0a 0d 0a 73 32 20 69 73 20 61 20 63 77 61  )....s2 is a cwa
0110: 6c 2d 62 61 73 65 64 20 73 63 72 69 70 74 69 6e  l-based scriptin
0120: 67 20 65 6e 67 69 6e 65 2c 20 5b 74 68 31 69 73  g engine, [th1is
0130: 68 5d 27 73 20 73 75 63 63 65 73 73 6f 72 2c 20  h]'s successor, 
0140: 61 6e 64 20 61 69 6d 73 20 61 74 20 74 68 65 20  and aims at the 
0150: 73 61 6d 65 20 6e 69 63 68 65 3a 20 61 20 73 6d  same niche: a sm
0160: 61 6c 6c 20 70 6c 61 74 66 6f 72 6d 20 66 6f 72  all platform for
0170: 20 61 64 64 69 6e 67 20 73 63 72 69 70 74 65 64   adding scripted
0180: 20 74 65 73 74 20 68 61 72 6e 65 73 73 65 73 20   test harnesses 
0190: 74 6f 20 43 20 6c 69 62 72 61 72 69 65 73 2e 20  to C libraries. 
01a0: 73 32 20 70 72 6f 76 69 64 65 73 20 61 20 4a 61  s2 provides a Ja
01b0: 76 61 53 63 72 69 70 74 2d 6c 69 6b 65 20 65 6e  vaScript-like en
01c0: 76 69 72 6f 6e 6d 65 6e 74 20 61 6e 64 20 69 73  vironment and is
01d0: 20 66 65 61 74 75 72 65 2d 63 6f 6d 70 6c 65 74   feature-complet
01e0: 65 2e 20 45 78 70 65 72 69 65 6e 63 65 20 77 69  e. Experience wi
01f0: 74 68 20 74 68 31 69 73 68 20 28 77 68 69 63 68  th th1ish (which
0200: 20 73 32 20 73 75 72 70 61 73 73 65 73 20 69 6e   s2 surpasses in
0210: 20 61 6c 6d 6f 73 74 20 65 76 65 72 79 20 77 61   almost every wa
0220: 79 29 20 68 61 73 20 73 68 6f 77 6e 20 74 68 61  y) has shown tha
0230: 74 20 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67  t the underlying
0240: 20 65 6e 67 69 6e 65 20 63 61 6e 20 69 6e 20 66   engine can in f
0250: 61 63 74 20 64 6f 20 71 75 69 74 65 20 61 20 6c  act do quite a l
0260: 6f 74 20 6d 6f 72 65 20 74 68 61 6e 20 6a 75 73  ot more than jus
0270: 74 20 72 75 6e 20 75 6e 69 74 20 74 65 73 74 73  t run unit tests
0280: 2c 20 73 75 63 68 20 61 73 20 67 65 6e 65 72 61  , such as genera
0290: 74 69 6e 67 20 77 68 6f 6c 65 20 77 65 62 20 73  ting whole web s
02a0: 69 74 65 73 2e 20 46 6f 72 20 65 78 61 6d 70 6c  ites. For exampl
02b0: 65 2c 20 5b 68 74 74 70 3a 2f 2f 66 6f 73 73 69  e, [http://fossi
02c0: 6c 2e 77 61 6e 64 65 72 69 6e 67 68 6f 72 73 65  l.wanderinghorse
02d0: 2e 6e 65 74 2f 72 65 70 6f 73 2f 6c 69 62 66 6f  .net/repos/libfo
02e0: 73 73 69 6c 7c 6c 69 62 66 6f 73 73 69 6c 5d 20  ssil|libfossil] 
02f0: 75 73 65 73 20 5b 68 74 74 70 73 3a 2f 2f 64 6f  uses [https://do
0300: 63 73 2e 67 6f 6f 67 6c 65 2e 63 6f 6d 2f 64 6f  cs.google.com/do
0310: 63 75 6d 65 6e 74 2f 64 2f 31 33 67 52 53 6c 36  cument/d/13gRSl6
0320: 2d 62 6a 33 4c 56 2d 4f 4b 67 45 2d 42 73 71 76  -bj3LV-OKgE-Bsqv
0330: 71 46 33 33 55 46 59 57 33 6f 61 33 41 32 4f 4a  qF33UFYW3oa3A2OJ
0340: 43 35 51 53 59 2f 76 69 65 77 7c 63 75 73 74 6f  C5QSY/view|custo
0350: 6d 20 73 32 20 62 69 6e 64 69 6e 67 73 5d 20 74  m s2 bindings] t
0360: 6f 20 70 72 6f 76 69 64 65 20 73 71 6c 69 74 65  o provide sqlite
0370: 20 64 61 74 61 62 61 73 65 20 61 63 63 65 73 73   database access
0380: 2e 20 41 73 69 64 65 20 66 72 6f 6d 20 73 63 72  . Aside from scr
0390: 69 70 74 69 6e 67 20 74 65 73 74 20 68 61 72 6e  ipting test harn
03a0: 65 73 73 65 73 2c 20 69 74 20 63 61 6e 20 62 65  esses, it can be
03b0: 20 75 73 65 64 20 66 6f 72 20 67 65 6e 65 72 61   used for genera
03c0: 6c 2d 70 75 72 70 6f 73 65 20 73 63 72 69 70 74  l-purpose script
03d0: 69 6e 67 20 66 6f 72 20 61 20 76 61 72 69 65 74  ing for a variet
03e0: 79 20 6f 66 20 61 70 70 6c 69 63 61 74 69 6f 6e  y of application
03f0: 73 20 6f 72 20 6c 69 62 72 61 72 69 65 73 2c 20  s or libraries, 
0400: 70 72 6f 76 69 64 65 64 20 69 74 73 20 62 75 69  provided its bui
0410: 6c 74 2d 69 6e 20 6c 69 6d 69 74 73 20 61 72 65  lt-in limits are
0420: 20 72 65 73 70 65 63 74 65 64 20 28 6e 61 6d 65   respected (name
0430: 6c 79 2c 20 69 74 20 69 73 20 3c 65 6d 3e 73 74  ly, it is <em>st
0440: 72 69 63 74 6c 79 20 73 69 6e 67 6c 65 2d 74 68  rictly single-th
0450: 72 65 61 64 65 64 3c 2f 65 6d 3e 2c 20 68 61 73  readed</em>, has
0460: 20 68 69 67 68 6c 79 20 75 6e 63 6f 6e 76 65 6e   highly unconven
0470: 74 69 6f 6e 61 6c 20 73 79 6d 62 6f 6c 20 6c 6f  tional symbol lo
0480: 6f 6b 75 70 20 72 75 6c 65 73 2c 20 61 6e 64 20  okup rules, and 
0490: 69 6e 20 73 6f 6d 65 20 70 6c 61 63 65 73 20 73  in some places s
04a0: 61 63 72 69 66 69 63 65 73 20 70 65 72 66 6f 72  acrifices perfor
04b0: 6d 61 6e 63 65 20 69 6e 20 66 61 76 6f 72 20 6f  mance in favor o
04c0: 66 20 61 20 73 6d 61 6c 6c 65 72 20 6d 65 6d 6f  f a smaller memo
04d0: 72 79 20 66 6f 6f 74 70 72 69 6e 74 29 2e 0d 0a  ry footprint)...
04e0: 0d 0a 73 32 20 69 73 20 69 6e 74 65 6e 64 65 64  ..s2 is intended
04f0: 20 74 6f 20 62 65 20 65 6d 62 65 64 64 65 64 20   to be embedded 
0500: 64 69 72 65 63 74 6c 79 20 69 6e 74 6f 20 63 6c  directly into cl
0510: 69 65 6e 74 20 70 72 6f 6a 65 63 74 73 2c 20 61  ient projects, a
0520: 73 20 6f 70 70 6f 73 65 64 20 74 6f 20 62 65 69  s opposed to bei
0530: 6e 67 20 70 72 6f 76 69 64 65 64 20 61 73 20 61  ng provided as a
0540: 6e 20 65 78 74 65 72 6e 61 6c 20 6c 69 62 72 61  n external libra
0550: 72 79 20 28 74 68 6f 75 67 68 20 69 74 20 63 61  ry (though it ca
0560: 6e 20 62 65 20 75 73 65 64 20 74 68 61 74 20 77  n be used that w
0570: 61 79 2c 20 74 6f 6f 2c 20 6f 66 20 63 6f 75 72  ay, too, of cour
0580: 73 65 29 2c 20 61 6e 64 20 64 69 73 74 72 69 62  se), and distrib
0590: 75 74 65 73 20 61 73 20 32 20 73 6f 75 72 63 65  utes as 2 source
05a0: 20 66 69 6c 65 73 20 28 6f 6e 65 20 68 65 61 64   files (one head
05b0: 65 72 20 61 6e 64 20 6f 6e 65 20 43 20 66 69 6c  er and one C fil
05c0: 65 29 20 77 68 69 63 68 20 63 6c 69 65 6e 74 73  e) which clients
05d0: 20 73 69 6d 70 6c 79 20 63 6f 6d 70 69 6c 65 20   simply compile 
05e0: 72 69 67 68 74 20 69 6e 20 74 68 65 69 72 20 70  right in their p
05f0: 72 6f 6a 65 63 74 2e 20 54 6f 20 62 75 69 6c 64  roject. To build
0600: 20 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69   this distributi
0610: 6f 6e 2c 20 73 69 6d 70 6c 79 20 72 75 6e 20 22  on, simply run "
0620: 6d 61 6b 65 20 61 6d 61 6c 22 20 66 72 6f 6d 20  make amal" from 
0630: 74 68 65 20 5b 2f 64 69 72 2f 73 32 7c 73 32 20  the [/dir/s2|s2 
0640: 73 75 62 64 69 72 65 63 74 6f 72 79 5d 20 6f 66  subdirectory] of
0650: 20 74 68 65 20 73 6f 75 72 63 65 20 74 72 65 65   the source tree
0660: 2e 20 49 74 73 20 73 6f 75 72 63 65 73 20 64 6f  . Its sources do
0670: 20 3c 69 3e 6e 6f 74 3c 2f 69 3e 20 69 6e 63 6c   <i>not</i> incl
0680: 75 64 65 20 74 68 65 20 22 65 78 70 6f 72 74 73  ude the "exports
0690: 22 20 6e 65 65 64 65 64 20 66 6f 72 20 6d 61 6b  " needed for mak
06a0: 69 6e 67 20 61 20 57 69 6e 64 6f 77 73 2d 66 6f  ing a Windows-fo
06b0: 72 6d 61 74 20 44 4c 4c 2e 0d 0a 0d 0a 73 32 2c  rmat DLL.....s2,
06c0: 20 61 73 20 6f 66 20 74 68 69 73 20 77 72 69 74   as of this writ
06d0: 69 6e 67 20 28 32 30 31 34 31 32 30 37 29 2c 20  ing (20141207), 
06e0: 69 6d 70 6c 65 6d 65 6e 74 73 20 66 65 61 74 75  implements featu
06f0: 72 65 73 20 75 6e 64 72 65 61 6d 65 64 20 6f 66  res undreamed of
0700: 20 77 68 65 6e 20 74 68 65 20 63 77 61 6c 20 70   when the cwal p
0710: 72 6f 6a 65 63 74 20 77 61 73 20 73 74 61 72 74  roject was start
0720: 65 64 2c 20 70 75 73 68 69 6e 67 20 69 74 20 77  ed, pushing it w
0730: 65 6c 6c 20 70 61 73 74 20 61 6e 79 20 69 6e 69  ell past any ini
0740: 74 69 61 6c 20 76 69 73 69 6f 6e 73 20 66 6f 72  tial visions for
0750: 20 74 68 65 20 63 6f 64 65 2e 20 49 6e 20 70 61   the code. In pa
0760: 72 74 69 63 75 6c 61 72 2c 20 73 75 62 74 6c 65  rticular, subtle
0770: 20 72 65 66 69 6e 65 6d 65 6e 74 73 20 69 6e 20   refinements in 
0780: 74 68 65 20 67 61 72 62 61 67 65 20 63 6f 6c 6c  the garbage coll
0790: 65 63 74 69 6f 6e 20 69 6e 20 4e 6f 76 65 6d 62  ection in Novemb
07a0: 65 72 2f 44 65 63 65 6d 62 65 72 20 32 30 31 34  er/December 2014
07b0: 20 68 61 76 65 20 65 73 73 65 6e 74 69 61 6c 6c   have essentiall
07c0: 79 20 65 6e 64 65 64 20 61 6e 79 20 63 6f 6e 63  y ended any conc
07d0: 65 72 6e 73 20 69 20 66 6f 72 6d 65 72 6c 79 20  erns i formerly 
07e0: 68 61 64 20 61 62 6f 75 74 20 74 68 65 20 76 69  had about the vi
07f0: 61 62 69 6c 69 74 79 20 6f 66 20 74 68 65 20 47  ability of the G
0800: 43 20 63 6f 72 65 2e 20 28 54 68 61 74 27 73 20  C core. (That's 
0810: 6e 6f 74 20 74 6f 20 73 61 79 20 69 74 27 73 20  not to say it's 
0820: 62 75 6c 6c 65 74 2d 70 72 6f 6f 66 2c 20 62 75  bullet-proof, bu
0830: 74 20 74 68 65 20 62 69 67 67 65 73 74 20 6f 66  t the biggest of
0840: 20 74 68 65 20 6b 6e 6f 77 6e 20 47 43 20 64 65   the known GC de
0850: 61 74 68 2d 74 72 61 70 73 20 68 61 76 65 20 62  ath-traps have b
0860: 65 65 6e 20 61 64 65 71 75 61 74 65 6c 79 20 72  een adequately r
0870: 65 73 6f 6c 76 65 64 2e 29 20 54 68 61 74 20 73  esolved.) That s
0880: 61 69 64 2c 20 74 68 65 72 65 20 69 73 20 73 74  aid, there is st
0890: 69 6c 6c 20 3c 65 6d 3e 70 6c 65 6e 74 79 3c 2f  ill <em>plenty</
08a0: 65 6d 3e 20 6f 66 20 72 6f 6f 6d 20 66 6f 72 20  em> of room for 
08b0: 65 78 70 65 72 69 6d 65 6e 74 61 74 69 6f 6e 20  experimentation 
08c0: 61 6e 64 20 74 68 65 20 63 77 61 6c 2f 73 32 20  and the cwal/s2 
08d0: 63 6f 64 65 20 62 61 73 65 73 20 68 61 76 65 20  code bases have 
08e0: 70 72 6f 76 65 6e 20 74 6f 20 62 65 20 72 65 6c  proven to be rel
08f0: 61 74 69 76 65 6c 79 20 6f 70 65 6e 20 74 6f 20  atively open to 
0900: 65 78 70 65 72 69 6d 65 6e 74 61 74 69 6f 6e 2e  experimentation.
0910: 0d 0a 0d 0a 73 32 20 69 6e 63 6c 75 64 65 73 20  ....s2 includes 
0920: 61 20 68 65 61 64 65 72 2d 6f 6e 6c 79 20 43 2b  a header-only C+
0930: 2b 20 63 77 61 6c 2f 6e 61 74 69 76 65 20 74 79  + cwal/native ty
0940: 70 65 20 63 6f 6e 76 65 72 73 69 6f 6e 20 6c 61  pe conversion la
0950: 79 65 72 20 77 68 69 63 68 2c 20 75 73 69 6e 67  yer which, using
0960: 20 6f 6e 6c 79 20 74 65 6d 70 6c 61 74 65 20 76   only template v
0970: 6f 6f 64 6f 6f 2c 20 6c 69 74 65 72 61 6c 6c 79  oodoo, literally
0980: 20 63 6f 6e 76 65 72 74 73 20 6e 65 61 72 2d 61   converts near-a
0990: 72 62 69 74 72 61 72 79 20 43 2f 43 2b 2b 20 76  rbitrary C/C++ v
09a0: 61 6c 75 65 73 2c 20 66 75 6e 63 74 69 6f 6e 73  alues, functions
09b0: 2c 20 6d 65 74 68 6f 64 73 2c 20 6e 6f 6e 2d 66  , methods, non-f
09c0: 75 6e 63 74 69 6f 6e 20 6d 65 6d 62 65 72 73 2c  unction members,
09d0: 20 3c 65 6d 3e 61 6e 64 3c 2f 65 6d 3e 20 63 6f   <em>and</em> co
09e0: 6e 73 74 72 75 63 74 6f 72 73 20 20 74 6f 20 63  nstructors  to c
09f0: 77 61 6c 20 63 61 6c 6c 62 61 63 6b 20 66 75 6e  wal callback fun
0a00: 63 74 69 6f 6e 73 20 28 72 65 73 70 2e 20 61 63  ctions (resp. ac
0a10: 63 65 73 73 6f 72 2f 6d 75 74 61 74 6f 72 20 66  cessor/mutator f
0a20: 75 6e 63 74 69 6f 6e 73 29 20 77 69 74 68 20 63  unctions) with c
0a30: 6f 6d 70 6c 65 74 65 20 74 79 70 65 2d 20 61 6e  omplete type- an
0a40: 64 20 4e 55 4c 4c 2d 70 6f 69 6e 74 65 72 20 73  d NULL-pointer s
0a50: 61 66 65 74 79 20 75 73 69 6e 67 20 74 68 65 20  afety using the 
0a60: 6d 61 67 69 63 20 6f 66 20 43 2b 2b 20 74 65 6d  magic of C++ tem
0a70: 70 6c 61 74 65 73 2e 20 49 74 20 69 6e 63 6c 75  plates. It inclu
0a80: 64 65 73 20 61 20 6d 65 63 68 61 6e 69 73 6d 20  des a mechanism 
0a90: 66 6f 72 20 64 65 66 69 6e 69 6e 67 20 63 6f 6d  for defining com
0aa0: 70 6c 65 78 20 63 61 6c 6c 62 61 63 6b 20 64 69  plex callback di
0ab0: 73 70 61 74 63 68 69 6e 67 20 72 75 6c 65 73 2c  spatching rules,
0ac0: 20 63 72 65 61 74 65 64 20 75 73 69 6e 67 20 6f   created using o
0ad0: 6e 6c 79 20 74 79 70 65 64 65 66 73 2c 20 74 6f  nly typedefs, to
0ae0: 20 72 6f 75 74 65 20 73 63 72 69 70 74 2d 62 61   route script-ba
0af0: 73 65 64 20 63 61 6c 6c 73 20 74 6f 20 6f 6e 65  sed calls to one
0b00: 20 6f 66 20 61 6e 79 20 6e 75 6d 62 65 72 20 6f   of any number o
0b10: 66 20 70 6f 74 65 6e 74 69 61 6c 20 6e 61 74 69  f potential nati
0b20: 76 65 20 66 75 6e 63 74 69 6f 6e 73 2e 20 53 65  ve functions. Se
0b30: 65 20 5b 2f 66 69 6e 66 6f 2f 73 32 2f 63 77 61  e [/finfo/s2/cwa
0b40: 6c 5f 63 6f 6e 76 65 72 74 2e 68 70 70 7c 73 32  l_convert.hpp|s2
0b50: 2f 63 77 61 6c 5f 63 6f 6e 76 65 72 74 2e 68 70  /cwal_convert.hp
0b60: 70 5d 20 66 6f 72 20 64 65 74 61 69 6c 73 20 61  p] for details a
0b70: 6e 64 20 5b 2f 66 69 6e 66 6f 2f 73 32 2f 73 61  nd [/finfo/s2/sa
0b80: 6d 70 6c 65 5f 63 70 70 32 2e 63 70 70 7c 73 32  mple_cpp2.cpp|s2
0b90: 2f 73 61 6d 70 6c 65 5f 63 70 70 32 2e 63 70 70  /sample_cpp2.cpp
0ba0: 5d 20 61 6e 64 20 5b 2f 66 69 6e 66 6f 2f 73 32  ] and [/finfo/s2
0bb0: 2f 73 61 6d 70 6c 65 5f 63 70 70 32 2e 73 32 7c  /sample_cpp2.s2|
0bc0: 73 32 2f 73 61 6d 70 6c 65 5f 63 70 70 32 2e 73  s2/sample_cpp2.s
0bd0: 32 5d 20 66 6f 72 20 65 78 61 6d 70 6c 65 73 2e  2] for examples.
0be0: 20 57 68 69 6c 65 20 69 74 20 63 75 72 72 65 6e   While it curren
0bf0: 74 6c 79 20 6c 69 76 65 73 20 69 6e 20 74 68 65  tly lives in the
0c00: 20 73 32 20 64 69 72 65 63 74 6f 72 79 2c 20 69   s2 directory, i
0c10: 74 27 73 20 6e 6f 74 20 64 65 70 65 6e 64 65 6e  t's not dependen
0c20: 74 20 6f 6e 20 73 32 2c 20 61 6e 64 20 63 61 6e  t on s2, and can
0c30: 20 77 6f 72 6b 20 77 69 74 68 20 61 6e 79 20 63   work with any c
0c40: 77 61 6c 20 63 6c 69 65 6e 74 20 63 6f 64 65 2e  wal client code.
0c50: 20 54 68 65 20 43 2b 2b 20 6c 61 79 65 72 20 73   The C++ layer s
0c60: 61 76 65 73 20 73 6f 20 6d 75 63 68 20 77 6f 72  aves so much wor
0c70: 6b 20 28 77 72 69 74 69 6e 67 20 61 6e 64 20 74  k (writing and t
0c80: 65 73 74 69 6e 67 20 63 6f 64 65 29 20 74 68 61  esting code) tha
0c90: 74 20 69 74 27 73 20 61 20 63 6f 6d 70 65 6c 6c  t it's a compell
0ca0: 69 6e 67 20 6f 70 74 69 6f 6e 20 66 6f 72 20 77  ing option for w
0cb0: 72 69 74 69 6e 67 20 62 69 6e 64 69 6e 67 73 20  riting bindings 
0cc0: 65 76 65 6e 20 77 68 65 6e 20 74 68 65 20 72 65  even when the re
0cd0: 73 74 20 6f 66 20 74 68 65 20 68 6f 73 74 20 70  st of the host p
0ce0: 72 6f 6a 65 63 74 20 69 73 20 70 75 72 65 20 43  roject is pure C
0cf0: 2e 0d 0a 0d 0a 0d 0a 3c 73 74 72 6f 6e 67 3e 44  .......<strong>D
0d00: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 3a 3c 2f 73  ocumentation:</s
0d10: 74 72 6f 6e 67 3e 0d 0a 0d 0a 20 20 2a 20 20 73  trong>....  *  s
0d20: 32 20 69 73 20 64 6f 63 75 6d 65 6e 74 65 64 20  2 is documented 
0d30: 69 6e 20 61 20 66 61 69 72 20 61 6d 6f 75 6e 74  in a fair amount
0d40: 20 6f 66 20 64 65 74 61 69 6c 20 69 6e 20 5b 68   of detail in [h
0d50: 74 74 70 73 3a 2f 2f 64 6f 63 73 2e 67 6f 6f 67  ttps://docs.goog
0d60: 6c 65 2e 63 6f 6d 2f 64 6f 63 75 6d 65 6e 74 2f  le.com/document/
0d70: 64 2f 31 68 76 4d 6f 48 53 49 7a 39 34 64 6f 62  d/1hvMoHSIz94dob
0d80: 36 66 43 55 36 53 4c 78 6c 65 5f 73 37 59 4c 36  6fCU6SLxle_s7YL6
0d90: 43 72 41 5f 34 61 55 31 32 4f 57 77 57 59 2f 76  CrA_4aU12OWwWY/v
0da0: 69 65 77 7c 74 68 69 73 20 70 75 62 6c 69 63 20  iew|this public 
0db0: 47 6f 6f 67 6c 65 20 44 6f 63 75 6d 65 6e 74 5d  Google Document]
0dc0: 0d 0a 20 20 2a 20 20 44 6f 63 73 20 66 6f 72 20  ..  *  Docs for 
0dd0: 22 73 75 70 70 6c 65 6d 65 6e 74 61 6c 22 20 28  "supplemental" (
0de0: 6e 6f 6e 2d 63 6f 72 65 29 20 73 63 72 69 70 74  non-core) script
0df0: 20 41 50 49 73 20 61 6e 64 20 6c 6f 61 64 61 62   APIs and loadab
0e00: 6c 65 20 6d 6f 64 75 6c 65 73 20 63 61 6e 20 62  le modules can b
0e10: 65 20 66 6f 75 6e 64 20 5b 68 74 74 70 73 3a 2f  e found [https:/
0e20: 2f 64 6f 63 73 2e 67 6f 6f 67 6c 65 2e 63 6f 6d  /docs.google.com
0e30: 2f 64 6f 63 75 6d 65 6e 74 2f 64 2f 31 34 67 52  /document/d/14gR
0e40: 50 34 66 2d 57 57 67 57 4e 53 36 34 4b 4d 5f 42  P4f-WWgWNS64KM_B
0e50: 49 37 59 6a 51 71 42 4c 6c 34 57 54 33 6a 49 72  I7YjQqBLl4WT3jIr
0e60: 6d 4e 6d 46 65 66 59 55 2f 76 69 65 77 7c 68 65  mNmFefYU/view|he
0e70: 72 65 5d 0d 0a 20 20 2a 20 20 54 68 65 20 5b 68  re]..  *  The [h
0e80: 74 74 70 3a 2f 2f 66 6f 73 73 69 6c 2e 77 61 6e  ttp://fossil.wan
0e90: 64 65 72 69 6e 67 68 6f 72 73 65 2e 6e 65 74 2f  deringhorse.net/
0ea0: 72 65 70 6f 73 2f 6c 69 62 66 6f 73 73 69 6c 2f  repos/libfossil/
0eb0: 7c 6c 69 62 66 6f 73 73 69 6c 20 62 69 6e 64 69  |libfossil bindi
0ec0: 6e 67 73 5d 20 64 6f 63 73 20 63 61 6e 20 62 65  ngs] docs can be
0ed0: 20 66 6f 75 6e 64 20 69 6e 20 5b 68 74 74 70 73   found in [https
0ee0: 3a 2f 2f 64 6f 63 73 2e 67 6f 6f 67 6c 65 2e 63  ://docs.google.c
0ef0: 6f 6d 2f 64 6f 63 75 6d 65 6e 74 2f 64 2f 31 33  om/document/d/13
0f00: 67 52 53 6c 36 2d 62 6a 33 4c 56 2d 4f 4b 67 45  gRSl6-bj3LV-OKgE
0f10: 2d 42 73 71 76 71 46 33 33 55 46 59 57 33 6f 61  -BsqvqF33UFYW3oa
0f20: 33 41 32 4f 4a 43 35 51 53 59 2f 76 69 65 77 7c  3A2OJC5QSY/view|
0f30: 68 65 72 65 5d 2e 0d 0a 0d 0a 54 68 6f 73 65 20  here].....Those 
0f40: 64 6f 63 75 6d 65 6e 74 73 20 28 69 6e 20 70 61  documents (in pa
0f50: 72 74 69 63 75 6c 61 72 20 74 68 65 20 66 69 72  rticular the fir
0f60: 73 74 20 74 77 6f 29 20 61 72 65 20 22 74 68 65  st two) are "the
0f70: 22 20 70 6c 61 63 65 20 66 6f 72 20 61 6c 6c 20  " place for all 
0f80: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75  information abou
0f90: 74 20 73 32 20 28 74 6f 74 61 6c 69 6e 67 20 77  t s2 (totaling w
0fa0: 65 6c 6c 20 6f 76 65 72 20 31 36 30 20 70 61 67  ell over 160 pag
0fb0: 65 73 2c 20 61 73 20 6f 66 20 32 30 31 36 30 32  es, as of 201602
0fc0: 32 35 29 2c 20 62 75 74 20 68 65 72 65 27 73 20  25), but here's 
0fd0: 61 20 62 72 69 65 66 20 6f 76 65 72 76 69 65 77  a brief overview
0fe0: 20 20 6f 66 20 69 74 73 20 70 72 69 6d 61 72 79    of its primary
0ff0: 20 61 64 76 61 6e 74 61 67 65 73 20 6f 76 65 72   advantages over
1000: 20 5b 74 68 31 69 73 68 5d 3a 0d 0a 0d 0a 20 20   [th1ish]:....  
1010: 20 2a 20 20 74 68 31 69 73 68 20 69 73 20 66 61   *  th1ish is fa
1020: 69 72 6c 79 20 6c 69 67 68 74 20 63 6f 6d 70 61  irly light compa
1030: 72 65 64 20 74 6f 20 61 6c 6c 20 6f 74 68 65 72  red to all other
1040: 20 65 6e 67 69 6e 65 73 20 69 20 63 6f 6d 70 61   engines i compa
1050: 72 65 64 20 69 74 20 74 6f 2c 20 62 75 74 20 73  red it to, but s
1060: 32 20 69 73 20 6c 69 67 68 74 65 72 2e 20 43 75  2 is lighter. Cu
1070: 72 72 65 6e 74 20 72 6f 75 67 68 20 65 73 74 69  rrent rough esti
1080: 6d 61 74 65 73 2c 20 62 61 73 65 64 20 6f 6e 20  mates, based on 
1090: 61 70 70 6c 65 73 2d 74 6f 2d 6f 72 61 6e 67 65  apples-to-orange
10a0: 73 20 63 6f 6d 70 61 72 69 73 6f 6e 73 2c 20 70  s comparisons, p
10b0: 75 74 20 69 74 20 61 74 20 6a 75 73 74 20 6f 76  ut it at just ov
10c0: 65 72 20 68 61 6c 66 20 61 73 20 6d 75 63 68 20  er half as much 
10d0: 6d 65 6d 6f 72 79 20 61 73 20 74 68 31 69 73 68  memory as th1ish
10e0: 20 66 6f 72 20 74 68 65 20 75 6e 69 74 20 74 65   for the unit te
10f0: 73 74 73 20 61 6e 64 20 66 61 72 20 6c 65 73 73  sts and far less
1100: 20 66 6f 72 20 6d 6f 72 65 20 67 65 6e 65 72 69   for more generi
1110: 63 20 77 6f 72 6b 2e 0d 0a 20 20 20 2a 20 20 41  c work...   *  A
1120: 20 73 74 61 63 6b 2d 6d 61 63 68 69 6e 65 2d 62   stack-machine-b
1130: 61 73 65 64 20 65 76 61 6c 75 61 74 69 6f 6e 20  ased evaluation 
1140: 65 6e 67 69 6e 65 20 28 74 68 31 69 73 68 20 69  engine (th1ish i
1150: 73 20 70 75 72 65 20 72 65 63 75 72 73 69 76 65  s pure recursive
1160: 2d 64 65 73 63 65 6e 74 2c 20 61 6e 64 20 68 61  -descent, and ha
1170: 73 20 6e 6f 20 73 74 61 63 6b 20 6d 61 63 68 69  s no stack machi
1180: 6e 65 29 2e 20 53 75 70 70 6f 72 74 73 20 43 2f  ne). Supports C/
1190: 43 2b 2b 20 6f 70 65 72 61 74 6f 72 20 70 72 65  C++ operator pre
11a0: 63 65 64 65 6e 63 65 2c 20 61 6e 64 20 61 64 64  cedence, and add
11b0: 69 6e 67 20 6e 65 77 20 6f 70 65 72 61 74 6f 72  ing new operator
11c0: 73 20 69 73 20 6e 6f 72 6d 61 6c 6c 79 20 61 20  s is normally a 
11d0: 73 69 6d 70 6c 65 20 6d 61 6e 6e 65 72 20 28 75  simple manner (u
11e0: 6e 6c 69 6b 65 20 69 6e 20 74 68 31 69 73 68 2c  nlike in th1ish,
11f0: 20 77 68 65 72 65 20 69 74 20 63 6f 75 6c 64 20   where it could 
1200: 62 65 20 71 75 69 74 65 20 64 69 66 66 69 63 75  be quite difficu
1210: 6c 74 29 2e 0d 0a 20 20 20 2a 20 20 4d 75 63 68  lt)...   *  Much
1220: 20 65 61 73 69 65 72 20 74 6f 20 6d 61 69 6e 74   easier to maint
1230: 61 69 6e 20 28 69 6e 74 65 72 6e 61 6c 6c 79 29  ain (internally)
1240: 20 64 75 65 20 74 6f 20 61 20 62 65 74 74 65 72   due to a better
1250: 20 73 65 70 61 72 61 74 69 6f 6e 20 6f 66 20 64   separation of d
1260: 75 74 69 65 73 20 62 65 74 77 65 65 6e 20 74 68  uties between th
1270: 65 20 70 61 72 73 65 72 20 61 6e 64 20 74 68 65  e parser and the
1280: 20 73 74 61 63 6b 20 6d 61 63 68 69 6e 65 2e 0d   stack machine..
1290: 0a 20 20 20 2a 20 20 41 20 63 6c 65 61 6e 65 64  .   *  A cleaned
12a0: 20 75 70 2c 20 6d 6f 72 65 20 66 6c 65 78 69 62   up, more flexib
12b0: 6c 65 20 73 79 6e 74 61 78 2e 20 53 75 70 70 6f  le syntax. Suppo
12c0: 72 74 73 20 4a 61 76 61 53 63 72 69 70 74 2d 73  rts JavaScript-s
12d0: 74 79 6c 65 20 69 6e 6c 69 6e 65 64 20 41 72 72  tyle inlined Arr
12e0: 61 79 73 20 61 6e 64 20 4f 62 6a 65 63 74 73 2c  ays and Objects,
12f0: 20 61 73 20 77 65 6c 6c 20 61 73 20 74 68 65 20   as well as the 
1300: 3c 74 74 3e 3c 6e 6f 77 69 6b 69 3e 5b 62 72 61  <tt><nowiki>[bra
1310: 63 65 73 5d 3c 2f 6e 6f 77 69 6b 69 3e 3c 2f 74  ces]</nowiki></t
1320: 74 3e 20 70 72 6f 70 65 72 74 79 20 61 63 63 65  t> property acce
1330: 73 73 20 6f 70 65 72 61 74 6f 72 2e 20 49 74 20  ss operator. It 
1340: 61 6c 73 6f 20 64 6f 65 73 20 61 77 61 79 20 77  also does away w
1350: 69 74 68 20 6d 6f 73 74 20 6f 66 20 74 68 31 69  ith most of th1i
1360: 73 68 27 73 20 54 43 4c 20 68 65 72 69 74 61 67  sh's TCL heritag
1370: 65 2c 20 67 6f 69 6e 67 20 6d 6f 72 65 20 66 6f  e, going more fo
1380: 72 20 4a 61 76 61 53 63 72 69 70 74 2d 6c 69 6b  r JavaScript-lik
1390: 65 2e 0d 0a 20 20 20 2a 20 20 54 68 65 20 6f 6e  e...   *  The on
13a0: 6c 79 20 77 61 79 20 69 6e 20 77 68 69 63 68 20  ly way in which 
13b0: 74 68 31 69 73 68 20 69 73 20 70 6f 74 65 6e 74  th1ish is potent
13c0: 69 61 6c 6c 79 20 73 75 70 65 72 69 6f 72 20 69  ially superior i
13d0: 73 20 74 6f 6b 65 6e 69 7a 61 74 69 6f 6e 20 73  s tokenization s
13e0: 70 65 65 64 2e 20 74 68 31 69 73 68 20 70 72 65  peed. th1ish pre
13f0: 2d 74 6f 6b 65 6e 69 7a 65 73 20 61 6e 20 65 6e  -tokenizes an en
1400: 74 69 72 65 20 73 63 72 69 70 74 20 61 6e 64 20  tire script and 
1410: 69 6e 74 65 72 6e 61 6c 6c 79 20 77 6f 72 6b 73  internally works
1420: 20 77 69 74 68 20 61 20 68 69 67 68 65 72 2d 6c   with a higher-l
1430: 65 76 65 6c 20 6c 69 6e 6b 65 64 20 6c 69 73 74  evel linked list
1440: 20 6f 66 20 74 6f 6b 65 6e 73 20 77 68 69 63 68   of tokens which
1450: 20 28 6e 6f 72 6d 61 6c 6c 79 29 20 74 61 6b 65   (normally) take
1460: 20 75 70 20 3c 65 6d 3e 6d 75 63 68 3c 2f 65 6d   up <em>much</em
1470: 3e 20 6d 6f 72 65 20 6d 65 6d 6f 72 79 20 74 68  > more memory th
1480: 61 6e 20 74 68 65 20 69 6e 70 75 74 73 2e 20 73  an the inputs. s
1490: 32 20 74 6f 6b 65 6e 69 7a 65 73 20 6f 6e 65 20  2 tokenizes one 
14a0: 74 6f 6b 65 6e 20 61 74 20 61 20 74 69 6d 65 2c  token at a time,
14b0: 20 61 6e 64 20 68 61 73 20 74 6f 20 72 65 2d 74   and has to re-t
14c0: 6f 6b 65 6e 69 7a 65 73 20 70 61 72 74 73 20 6f  okenizes parts o
14d0: 66 20 61 20 73 63 72 69 70 74 20 69 74 20 74 72  f a script it tr
14e0: 61 76 65 72 73 65 73 20 6d 6f 72 65 20 74 68 61  averses more tha
14f0: 6e 20 6f 6e 63 65 20 28 65 2e 67 2e 2c 20 6c 6f  n once (e.g., lo
1500: 6f 70 20 61 6e 64 20 66 75 6e 63 74 69 6f 6e 20  op and function 
1510: 62 6f 64 69 65 73 29 2e 20 43 6f 6d 70 75 74 61  bodies). Computa
1520: 74 69 6f 6e 61 6c 6c 79 20 73 70 65 61 6b 69 6e  tionally speakin
1530: 67 2c 20 74 68 6f 75 67 68 20 69 74 20 68 61 73  g, though it has
1540: 6e 27 74 20 62 65 65 6e 20 6d 65 61 73 75 72 65  n't been measure
1550: 64 2c 20 74 68 31 69 73 68 27 73 20 65 76 61 6c  d, th1ish's eval
1560: 75 61 74 69 6f 6e 20 65 6e 67 69 6e 65 20 69 73  uation engine is
1570: 20 66 61 73 74 65 72 20 69 6e 20 74 68 61 74 20   faster in that 
1580: 72 65 67 61 72 64 2e 20 48 6f 77 65 76 65 72 2c  regard. However,
1590: 20 73 32 27 73 20 63 6f 72 65 20 65 76 61 6c 75   s2's core evalu
15a0: 61 74 69 6f 6e 20 65 6e 67 69 6e 65 20 69 73 20  ation engine is 
15b0: 28 63 6f 6d 70 75 74 61 74 69 6f 6e 61 6c 6c 79  (computationally
15c0: 20 73 70 65 61 6b 69 6e 67 29 20 66 61 73 74 65   speaking) faste
15d0: 72 2c 20 77 68 69 63 68 20 22 6d 69 67 68 74 22  r, which "might"
15e0: 20 6d 61 6b 65 20 75 70 20 66 6f 72 20 74 68 65   make up for the
15f0: 20 72 65 2d 74 6f 6b 65 6e 69 7a 61 74 69 6f 6e   re-tokenization
1600: 20 65 66 66 6f 72 74 73 2e 20 49 74 20 68 61 73   efforts. It has
1610: 6e 27 74 20 62 65 65 6e 20 6d 65 61 73 75 72 65  n't been measure
1620: 64 20 62 65 63 61 75 73 65 20 74 68 65 79 20 61  d because they a
1630: 72 65 20 77 68 61 74 20 74 68 65 79 20 61 72 65  re what they are
1640: 20 61 6e 64 20 74 68 31 69 73 68 20 69 73 20 6e   and th1ish is n
1650: 6f 77 20 6f 62 73 6f 6c 65 74 65 2c 20 73 6f 20  ow obsolete, so 
1660: 69 74 27 73 20 6e 6f 74 20 77 6f 72 74 68 20 73  it's not worth s
1670: 70 65 6e 64 69 6e 67 20 6d 75 63 68 20 65 66 66  pending much eff
1680: 6f 72 74 20 6f 6e 2e 0d 0a 0d 0a 41 6c 6c 20 74  ort on.....All t
1690: 68 61 74 20 62 65 69 6e 67 20 73 61 69 64 2c 20  hat being said, 
16a0: 73 32 20 72 65 75 73 65 73 20 28 77 65 6c 6c 2c  s2 reuses (well,
16b0: 20 63 6f 70 79 2f 70 61 73 74 65 73 29 20 74 68   copy/pastes) th
16c0: 65 20 76 61 73 74 20 6d 61 6a 6f 72 69 74 79 20  e vast majority 
16d0: 6f 66 20 74 68 31 69 73 68 27 73 20 70 72 6f 74  of th1ish's prot
16e0: 6f 74 79 70 65 2d 6c 65 76 65 6c 20 69 6e 66 72  otype-level infr
16f0: 61 73 74 72 75 63 74 75 72 65 2c 20 61 73 20 77  astructure, as w
1700: 65 6c 6c 20 61 73 20 69 74 73 20 6d 6f 64 75 6c  ell as its modul
1710: 65 20 6c 6f 61 64 65 72 2e 20 49 74 20 61 6c 73  e loader. It als
1720: 6f 20 6c 65 76 65 72 61 67 65 64 20 61 20 6c 6f  o leveraged a lo
1730: 74 20 6f 66 20 65 78 70 65 72 69 65 6e 63 65 20  t of experience 
1740: 67 61 69 6e 65 64 20 66 72 6f 6d 20 64 65 76 65  gained from deve
1750: 6c 6f 70 69 6e 67 20 74 68 31 69 73 68 2c 20 61  loping th1ish, a
1760: 6c 6c 6f 77 69 6e 67 20 69 74 20 74 6f 20 62 65  llowing it to be
1770: 20 63 72 65 61 74 65 64 20 66 72 6f 6d 20 73 63   created from sc
1780: 72 61 74 63 68 20 77 69 74 68 20 61 62 6f 75 74  ratch with about
1790: 20 35 20 77 65 65 6b 73 20 61 6e 64 20 72 6f 75   5 weeks and rou
17a0: 67 68 6c 79 20 32 30 30 20 63 6f 6d 6d 69 74 73  ghly 200 commits
17b0: 20 6f 66 20 65 66 66 6f 72 74 2e 20 74 68 31 69   of effort. th1i
17c0: 73 68 27 73 20 66 69 72 73 74 20 65 64 69 74 69  sh's first editi
17d0: 6f 6e 20 74 6f 6f 6b 20 72 6f 75 67 68 6c 79 20  on took roughly 
17e0: 31 30 20 77 65 65 6b 73 20 61 6e 64 20 77 65 6c  10 weeks and wel
17f0: 6c 20 6d 6f 72 65 20 74 68 61 6e 20 74 77 69 63  l more than twic
1800: 65 20 61 73 20 6d 61 6e 79 20 63 6f 6d 6d 69 74  e as many commit
1810: 73 2e 20 4d 75 63 68 20 6f 66 20 74 68 61 74 20  s. Much of that 
1820: 28 62 61 73 69 63 61 6c 6c 79 20 65 76 65 72 79  (basically every
1830: 74 68 69 6e 67 20 6f 75 74 73 69 64 65 20 74 68  thing outside th
1840: 65 20 63 6f 72 65 20 65 76 61 6c 75 61 74 69 6f  e core evaluatio
1850: 6e 20 65 6e 67 69 6e 65 29 20 77 61 73 20 63 6f  n engine) was co
1860: 64 65 20 77 68 69 63 68 20 73 32 20 67 6f 74 20  de which s2 got 
1870: 74 6f 20 73 74 65 61 6c 20 6f 75 74 72 69 67 68  to steal outrigh
1880: 74 2c 20 73 61 76 69 6e 67 20 61 20 6c 6f 74 20  t, saving a lot 
1890: 6f 66 20 74 69 6d 65 20 6f 6e 20 74 68 69 73 20  of time on this 
18a0: 67 6f 2d 61 72 6f 75 6e 64 2e 20 49 74 20 74 75  go-around. It tu
18b0: 72 6e 73 20 6f 75 74 20 74 68 61 74 20 6d 6f 73  rns out that mos
18c0: 74 20 63 6f 64 65 20 61 74 20 74 68 65 20 70 72  t code at the pr
18d0: 6f 74 6f 74 79 70 65 2f 63 6c 61 73 73 20 6c 65  ototype/class le
18e0: 76 65 6c 20 64 65 70 65 6e 64 73 20 6f 6e 6c 79  vel depends only
18f0: 20 6f 6e 20 74 68 65 20 63 6f 72 65 20 65 6e 67   on the core eng
1900: 69 6e 65 20 28 63 77 61 6c 29 2c 20 6e 6f 74 20  ine (cwal), not 
1910: 74 68 65 20 73 63 72 69 70 74 20 6c 61 6e 67 75  the script langu
1920: 61 67 65 20 28 74 68 31 69 73 68 20 6f 72 20 73  age (th1ish or s
1930: 32 29 2c 20 6d 61 6b 69 6e 67 20 69 74 20 65 61  2), making it ea
1940: 73 79 20 74 6f 20 73 68 61 72 65 20 43 2d 6c 65  sy to share C-le
1950: 76 65 6c 20 63 6f 64 65 20 62 65 74 77 65 65 6e  vel code between
1960: 20 74 68 65 20 74 77 6f 20 63 77 61 6c 20 63 6c   the two cwal cl
1970: 69 65 6e 74 73 2e 0a 5a 20 39 33 66 38 64 38 30  ients..Z 93f8d80
1980: 65 33 30 30 37 61 61 63 61 35 62 38 34 30 65 37  e3007aaca5b840e7
1990: 36 39 31 36 36 36 62 35 31 0a                    691666b51.