home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / tcl / 1262 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  3.6 KB

  1. Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!cs1.cc.lehigh.edu!tbrannon
  2. From: tbrannon@mars.csee.lehigh.edu (tbrannon)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Announcing calc_object
  5. Message-ID: <TBRANNON.92Aug27085346@mars.csee.lehigh.edu>
  6. Date: 27 Aug 92 13:53:46 GMT
  7. Sender: usenet@chili.cc.lehigh.edu
  8. Organization: AI-LAB, Electrical Engineering and Computer Science, Lehigh
  9.     University
  10. Lines: 93
  11. Nntp-Posting-Host: mars.csee.lehigh.edu
  12.  
  13.  
  14. # --- Calc Object
  15.  
  16. Calc object's intent is to allow a more natural expression of
  17. mathematics in Tcl programs by allowing the programmer to spit
  18. commands at lightweight calc objects. 
  19.  
  20. These calc objects do their work through Expect, a program written by
  21. Don Libes (libes@cme.nist.gov). Expect allows a user to control stdin,
  22. stdout and stderr of interactive processes in a way not possible by
  23. the Unix shell. Each created calc object has control over a bc(1)
  24. process. Each string sent to the calc object is passed along untouched to bc.
  25. The calc object then waits for bc's output and then returns it to the 
  26. user.
  27.  
  28. # -- Example Use
  29.  
  30. From the shell I type expect (or expecTerm) and get a prompt:
  31.  
  32. expect0.0> bc_init calc_object_1
  33. expect0.0> set two_pi [calc_object  2 * 3.14 ]
  34. expect0.0> bc_init calc_object_2
  35. expect0.0> calc_object_2  scale=6
  36. expect0.0> set half_pi [calc_object_2  3.14 /2]
  37. expect0.0> set sum_a [calc_object_1 $two_pi + $half_pi]
  38.  
  39. # -- Comparision with expr (page 6 of Tcl man page)
  40.  
  41. Since calc objects are simply Tcl interfaces to a bc(1) process, calc
  42. objects can only receive a string or list of strings for evaluation.
  43. In contrast, it is possible with expr to write code like so:
  44.  
  45. set size [expr 5/([length "abcd" chars]+0.0)]
  46.  
  47. Calc objects allow spacing between the + , - , / , and * operands
  48. while expr does not.
  49.  
  50. # -- Its Purpose
  51.  
  52. Prototype for interface to interpreted languages which have a textual
  53. representation for their data. Once we can interface to the
  54. interpreted languages in the object-oriented fashion displayed here,
  55. we can make use of any language we want (e.g. GNU Smalltalk, Python)
  56. at will. An impossible but desirable task is to be able to link in GNU Emacs
  57. software. This is impossible because GNU Emacs does not provide a
  58. command line interface to its functions and data. 
  59.  
  60. # -- Requirements for Use or Trying out Calc Object
  61.  
  62. Tcl6.4 from "/anonymous@sprite.berkeley.edu:/tcl"
  63. Expect from "/anonymous@durer.cme.nist.gov:/pub/expect"
  64.  
  65. # -- Installation
  66.  
  67. Change the requirement for main.c under CFILES and for main.o under OFILES in the Makefile of the expect/expecTerm distribution to my_main.c and
  68. my_main.o respectively and use the my_main.c included with this
  69. README. my_main.c adds three functions to the body of my_main.c and a
  70. called to init_bc_interpreter() in main(). 
  71.  
  72. I know that one generally patches the original source but in this case there
  73. are two versions of Expect out. One originally written by Don Libes and the
  74. second one with additional features for region pattern matching and terminal
  75. emulation by Mark Weissman.
  76.  
  77. # -- The Author
  78.  
  79. Terrence Brannon (tb06@pl122a.eecs.lehigh.edu) would like to thank Don
  80. Libes (libes@cme.nist.gov) for the creation of the excellent Expect
  81. utility. 
  82.  
  83. Suggestions, comments, expansion welcome.
  84.  
  85. --
  86. jintian wo jue de hao. ni ne? zhen de a! women dou hen hao ye hen haokan.
  87.  
  88.                    
  89.                   *
  90.                 *****
  91.                   *
  92.                   *********
  93.                   *  ***  *
  94.                   *********
  95.                   *
  96.                  ***
  97.                 * * *
  98.                    *  *  *
  99.                   *
  100.                  **
  101.                   *
  102.                               
  103.             Terrence Brannon             (tb06@ns1.cc.lehigh.edu)
  104.             medical biology via acupuncuture and particle physics
  105.         primitive knowledge shall reign supreme and I know it
  106.