Hex Artifact Content

Artifact a3de5c087d29067b8be1d0ebd0ed145f56395e66:


0000: 74 63 6c 2e 6a 73 20 22 41 20 54 63 6c 20 69 6d  tcl.js "A Tcl im
0010: 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 69 6e 20  plementation in 
0020: 4a 61 76 61 73 63 72 69 70 74 22 0a 0a 20 2a 20  Javascript".. * 
0030: 52 65 6c 65 61 73 65 64 20 75 6e 64 65 72 20 74  Released under t
0040: 68 65 20 73 61 6d 65 20 74 65 72 6d 73 20 61 73  he same terms as
0050: 20 54 63 6c 20 69 74 73 65 6c 66 2e 0a 20 2a 20   Tcl itself.. * 
0060: 28 42 53 44 20 6c 69 63 65 6e 73 65 20 66 6f 75  (BSD license fou
0070: 6e 64 20 61 74 20 3c 68 74 74 70 3a 2f 2f 77 77  nd at <http://ww
0080: 77 2e 74 63 6c 2e 74 6b 2f 73 6f 66 74 77 61 72  w.tcl.tk/softwar
0090: 65 2f 74 63 6c 74 6b 2f 6c 69 63 65 6e 73 65 2e  e/tcltk/license.
00a0: 68 74 6d 6c 3e 29 0a 20 2a 0a 20 2a 20 42 61 73  html>). *. * Bas
00b0: 65 64 20 6f 6e 20 50 69 63 6f 6c 20 62 79 20 53  ed on Picol by S
00c0: 61 6c 76 61 74 6f 72 65 20 53 61 6e 66 69 6c 69  alvatore Sanfili
00d0: 70 70 6f 20 28 3c 68 74 74 70 3a 2f 2f 61 6e 74  ppo (<http://ant
00e0: 69 72 65 7a 2e 63 6f 6d 2f 70 61 67 65 2f 70 69  irez.com/page/pi
00f0: 63 6f 6c 3e 29 0a 20 2a 20 28 63 29 20 53 74 c3  col>). * (c) St.
0100: a9 70 68 61 6e 65 20 41 72 6e 6f 6c 64 20 32 30  .phane Arnold 20
0110: 30 37 0a 20 2a 20 52 69 63 68 61 72 64 20 53 75  07. * Richard Su
0120: 63 68 65 6e 77 69 72 74 68 20 32 30 30 37 2c 20  chenwirth 2007, 
0130: 32 30 31 33 3a 20 63 6c 65 61 6e 75 70 2c 20 61  2013: cleanup, a
0140: 64 64 69 74 69 6f 6e 73 0a 0a 54 68 69 73 20 65  dditions..This e
0150: 6d 75 6c 61 74 65 73 20 28 69 6e 20 70 61 72 74  mulates (in part
0160: 29 20 61 6e 20 69 6e 74 65 72 70 72 65 74 65 72  ) an interpreter
0170: 20 66 6f 72 20 74 68 65 20 54 63 6c 20 73 63 72   for the Tcl scr
0180: 69 70 74 69 6e 67 20 6c 61 6e 67 75 61 67 65 2e  ipting language.
0190: 20 45 61 72 6c 79 20 76 65 72 73 69 6f 6e 73 20   Early versions 
01a0: 77 65 72 65 20 74 65 73 74 65 64 20 69 6e 20 62  were tested in b
01b0: 72 6f 77 73 65 72 73 2c 20 62 75 74 20 73 69 6e  rowsers, but sin
01c0: 63 65 20 74 68 65 20 61 64 76 65 6e 74 20 6f 66  ce the advent of
01d0: 20 6e 6f 64 65 2e 6a 73 2c 20 49 20 6f 6e 6c 79   node.js, I only
01e0: 20 75 73 65 20 74 68 61 74 2c 20 6c 69 6b 65 20   use that, like 
01f0: 61 20 74 63 6c 73 68 20 28 69 6e 74 65 72 61 63  a tclsh (interac
0200: 74 69 76 65 20 6f 72 20 77 69 74 68 20 73 63 72  tive or with scr
0210: 69 70 74 20 66 69 6c 65 28 73 29 20 74 6f 20 65  ipt file(s) to e
0220: 76 61 6c 75 61 74 65 29 2e 0a 0a 54 68 65 20 74  valuate)...The t
0230: 65 73 74 20 73 75 69 74 65 20 69 73 20 61 6c 73  est suite is als
0240: 6f 20 66 72 65 71 75 65 6e 74 6c 79 20 74 65 73  o frequently tes
0250: 74 65 64 20 61 67 61 69 6e 73 74 20 61 20 72 65  ted against a re
0260: 61 6c 20 74 63 6c 73 68 2c 20 63 75 72 72 65 6e  al tclsh, curren
0270: 74 6c 79 20 38 2e 35 2e 31 33 2e 20 4f 6e 6c 79  tly 8.5.13. Only
0280: 20 61 20 66 65 77 20 74 65 73 74 73 20 64 65 61   a few tests dea
0290: 6c 69 6e 67 20 77 69 74 68 20 73 70 65 63 69 61  ling with specia
02a0: 6c 20 6e 75 6d 62 65 72 73 20 28 49 6e 66 69 6e  l numbers (Infin
02b0: 69 74 79 2c 20 4e 61 4e 29 20 61 72 65 20 73 6b  ity, NaN) are sk
02c0: 69 70 70 65 64 20 77 68 65 6e 20 72 65 61 6c 20  ipped when real 
02d0: 54 63 6c 20 72 75 6e 73 2e 0a 0a 54 68 65 20 74  Tcl runs...The t
02e0: 63 6c 6a 73 20 70 72 6f 6a 65 63 74 20 68 61 73  cljs project has
02f0: 20 61 20 68 6f 6d 65 20 61 74 20 68 74 74 70 3a   a home at http:
0300: 2f 2f 63 6f 64 65 2e 67 6f 6f 67 6c 65 2e 63 6f  //code.google.co
0310: 6d 2f 70 2f 74 63 6c 2d 6a 73 2f 2e 20 0a 56 65  m/p/tcl-js/. .Ve
0320: 72 73 69 6f 6e 20 63 6f 6e 74 72 6f 6c 20 76 69  rsion control vi
0330: 61 20 6d 65 72 63 75 72 69 61 6c 20 28 68 67 29  a mercurial (hg)
0340: 2e 20 0a 41 6c 73 6f 20 76 69 61 20 46 6f 73 73  . .Also via Foss
0350: 69 6c 20 61 74 20 68 74 74 70 73 3a 2f 2f 63 68  il at https://ch
0360: 69 73 65 6c 61 70 70 2e 63 6f 6d 2f 75 73 65 72  iselapp.com/user
0370: 2f 73 75 63 68 65 6e 77 69 2f 72 65 70 6f 73 69  /suchenwi/reposi
0380: 74 6f 72 79 2f 74 63 6c 2d 6a 73 2f 64 69 72 3f  tory/tcl-js/dir?
0390: 63 69 3d 74 69 70 0a 0a 49 20 75 73 65 64 20 74  ci=tip..I used t
03a0: 6f 20 64 65 76 65 6c 6f 70 20 74 68 69 73 20 77  o develop this w
03b0: 69 74 68 20 6e 6f 64 65 2e 6a 73 20 76 30 2e 36  ith node.js v0.6
03c0: 2e 31 39 20 28 77 68 69 63 68 20 77 61 73 20 73  .19 (which was s
03d0: 74 61 6e 64 61 72 64 20 76 69 61 20 61 70 74 2d  tandard via apt-
03e0: 67 65 74 29 2e 20 4e 6f 77 20 74 68 61 74 20 62  get). Now that b
03f0: 61 63 6b 73 6c 61 73 68 20 65 73 63 61 70 65 73  ackslash escapes
0400: 20 61 72 65 20 66 69 6e 61 6c 6c 79 20 77 6f 72   are finally wor
0410: 6b 69 6e 67 2c 20 74 68 65 20 74 65 73 74 20 73  king, the test s
0420: 75 69 74 65 20 28 77 68 69 63 68 20 69 73 20 69  uite (which is i
0430: 6e 20 55 54 46 2d 38 29 20 6e 65 65 64 73 20 74  n UTF-8) needs t
0440: 6f 20 62 65 20 70 61 72 73 65 64 20 61 73 20 73  o be parsed as s
0450: 75 63 68 2c 20 73 6f 20 49 20 75 70 67 72 61 64  uch, so I upgrad
0460: 65 64 20 74 6f 20 6e 6f 64 65 2e 6a 73 20 76 30  ed to node.js v0
0470: 2e 31 30 2e 32 32 2e 0a 0a 4f 6e 20 74 68 65 20  .10.22...On the 
0480: 63 6f 6d 6d 61 6e 64 20 6c 69 6e 65 20 79 6f 75  command line you
0490: 20 63 61 6e 20 70 61 73 73 20 63 6f 64 65 20 73   can pass code s
04a0: 6e 69 70 70 65 74 73 20 74 68 61 74 20 61 72 65  nippets that are
04b0: 20 65 78 65 63 75 74 65 64 20 62 65 66 6f 72 65   executed before
04c0: 20 74 68 65 20 52 65 61 64 2d 45 76 61 6c 2d 50   the Read-Eval-P
04d0: 72 69 6e 74 20 6c 6f 6f 70 20 69 73 20 65 6e 74  rint loop is ent
04e0: 65 72 65 64 20 46 6f 72 20 69 6e 73 74 61 6e 63  ered For instanc
04f0: 65 2c 20 74 68 69 73 20 72 75 6e 73 20 74 68 65  e, this runs the
0500: 20 74 65 73 74 20 73 75 69 74 65 3a 0a 0a 24 20   test suite:..$ 
0510: 44 45 42 55 47 3d 30 20 6e 6f 64 65 20 74 63 6c  DEBUG=0 node tcl
0520: 30 35 33 2e 6a 73 20 22 73 6f 75 72 63 65 20 2f  053.js "source /
0530: 68 6f 6d 65 2f 73 75 63 68 65 6e 77 69 2f 74 63  home/suchenwi/tc
0540: 6c 2d 6a 73 2f 74 65 73 74 5f 74 63 6c 6a 73 2e  l-js/test_tcljs.
0550: 74 63 6c 22 0a 0a 57 69 74 68 20 44 45 42 55 47  tcl"..With DEBUG
0560: 3d 31 2c 20 61 6c 6c 20 63 6f 6d 6d 61 6e 64 73  =1, all commands
0570: 20 61 72 65 20 72 65 70 6f 72 74 65 64 20 62 65   are reported be
0580: 66 6f 72 65 20 65 78 65 63 75 74 69 6f 6e 2c 20  fore execution, 
0590: 61 6e 64 20 61 6c 6c 20 65 78 63 65 70 74 69 6f  and all exceptio
05a0: 6e 73 2e 0a 0a 53 74 69 6c 6c 20 6d 69 73 73 69  ns...Still missi
05b0: 6e 67 3a 0a 2d 20 62 6c 6f 63 6b 69 6e 67 20 5b  ng:.- blocking [
05c0: 65 78 65 63 5d 0a 2d 20 62 6c 6f 63 6b 69 6e 67  exec].- blocking
05d0: 20 5b 67 65 74 73 5d 0a 2d 20 5b 65 78 70 72 5d   [gets].- [expr]
05e0: 20 74 6f 20 61 6c 73 6f 20 61 63 63 65 70 74 20   to also accept 
05f0: 63 6f 6d 6d 61 6e 64 20 63 61 6c 6c 73 20 69 6e  command calls in
0600: 20 62 72 61 63 65 64 20 65 78 70 72 65 73 73 69   braced expressi
0610: 6f 6e 73 2c 20 65 2e 67 2e 0a 20 20 20 20 20 20  ons, e.g..      
0620: 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24    if {[llength $
0630: 78 5d 20 3e 20 32 7d 20 2e 2e 2e 0a 2d 20 5b 6f  x] > 2} ....- [o
0640: 70 65 6e 5d 2c 20 5b 70 75 74 73 5d 20 74 6f 20  pen], [puts] to 
0650: 66 69 6c 65 2c 20 5b 63 6c 6f 73 65 5d 0a 2d 0a  file, [close].-.
0660: 2d 20 61 6e 64 20 6d 61 6e 79 20 6d 6f 72 65 2e  - and many more.
0670: 2e 2e 0a                                         ...