From: tbrannon@mars.csee.lehigh.edu (tbrannon)
Newsgroups: comp.lang.tcl
Subject: Announcing calc_object
Date: 27 Aug 92 13:53:46 GMT
Organization: AI-LAB, Electrical Engineering and Computer Science, Lehigh
	University


# --- Calc Object

Calc object's intent is to allow a more natural expression of
mathematics in Tcl programs by allowing the programmer to spit
commands at lightweight calc objects. 

These calc objects do their work through Expect, a program written by
Don Libes (libes@cme.nist.gov). Expect allows a user to control stdin,
stdout and stderr of interactive processes in a way not possible by
the Unix shell. Each created calc object has control over a bc(1)
process. Each string sent to the calc object is passed along untouched to bc.
The calc object then waits for bc's output and then returns it to the 
user.

# -- Example Use

From the shell I type expect (or expecTerm) and get a prompt:

expect0.0> bc_init calc_object_1
expect0.0> set two_pi [calc_object  2 * 3.14 ]
expect0.0> bc_init calc_object_2
expect0.0> calc_object_2  scale=6
expect0.0> set half_pi [calc_object_2  3.14 /2]
expect0.0> set sum_a [calc_object_1 $two_pi + $half_pi]

# -- Comparision with expr (page 6 of Tcl man page)

Since calc objects are simply Tcl interfaces to a bc(1) process, calc
objects can only receive a string or list of strings for evaluation.
In contrast, it is possible with expr to write code like so:

set size [expr 5/([length "abcd" chars]+0.0)]

Calc objects allow spacing between the + , - , / , and * operands
while expr does not.

# -- Its Purpose

Prototype for interface to interpreted languages which have a textual
representation for their data. Once we can interface to the
interpreted languages in the object-oriented fashion displayed here,
we can make use of any language we want (e.g. GNU Smalltalk, Python)
at will. An impossible but desirable task is to be able to link in GNU Emacs
software. This is impossible because GNU Emacs does not provide a
command line interface to its functions and data. 

# -- Requirements for Use or Trying out Calc Object

Tcl6.4 from "/anonymous@sprite.berkeley.edu:/tcl"
Expect from "/anonymous@durer.cme.nist.gov:/pub/expect"

# -- Installation

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
my_main.o respectively and use the my_main.c included with this
README. my_main.c adds three functions to the body of my_main.c and a
called to init_bc_interpreter() in main(). 

I know that one generally patches the original source but in this case there
are two versions of Expect out. One originally written by Don Libes and the
second one with additional features for region pattern matching and terminal
emulation by Mark Weissman.

# -- The Author

Terrence Brannon (tb06@pl122a.eecs.lehigh.edu) would like to thank Don
Libes (libes@cme.nist.gov) for the creation of the excellent Expect
utility. 

Suggestions, comments, expansion welcome.

--
jintian wo jue de hao. ni ne? zhen de a! women dou hen hao ye hen haokan.

				   
				  *
				*****
				  *
			      *********
			      *  ***  *
			      *********
				  *
				 ***
				* * *
			       *  *  *
				  *
				 **
				  *
							  
            Terrence Brannon             (tb06@ns1.cc.lehigh.edu)
            medical biology via acupuncuture and particle physics
	    primitive knowledge shall reign supreme and I know it