I just want to add another fly in the ointment. Have you looked at S-Lang? I
claim that it is easier than TCL to embed into a C program. Here is a
description of S-Lang and details about where to get it:
The latest version of my C-like interpreter S-Lang is available. UNIKE
PREVIOUS VERSIONS, THE NEWEST VERSION MY BE USED OR DISTRIBUTED WITHOUT ANY
FEE OR ROYALTY. Details on where to ftp S-Lang from is presented below.
What is S-Lang? S-Lang is a very powerful stack based embedded interpreter
with a C-like language interface. This means that you can embed S-Lang into
your C program to give it a powerful scripting language with a friendly syntax
that resembles C. For example, here is a S-Lang function that computes that
the of a matrix:
define matrix_trace (a, n)
variable i, sum = 0;
if (n <= 0) error ("matrix_trace: n is less than 0");
for (i = 0; i < n; i++) sum += a[i, i];
Unlike alot of embedded interpreters currently freely available, S-Lang has a
familiar syntax for C programmers. It supports integer, string, and floating
point variable types. There is no need to worry about malloc/free or garbage
collection; S-Lang takes care of all of that, e.g.,
define three_string_cat (s1, s2, s3)
return strcat (s1, strcat (s2, s3));
print (three_string_cat ("Hello", "World", "!!!"));
Since S-Lang has builtin support for integer and floating point numbers, it is
much faster at doing arithemetic operations than interpreters which represent
everything in terms of strings (e.g., TCL).
S-Lang also supports automatic function loading. Consider the following
example from the JED editor which embedds S-Lang as its extension language.
JED has an info program written entirely in S-Lang which is roughly about 1000
lines long and is kept in a file called `info.sl'. JED's info mode is rarely
used and it does not make any sense to load it everytime the editor is used.
Instead, JED simply includes the line:
autoload ("info_mode", "info.sl");
in its main startup script. This tells the interpreter that if any function
tries to execute `info_mode', it must first be loaded from the file `info.sl'.
Since S-Lang was conceived from the start to be embedded into a C program, it
is very easy to incorporate S-Lang into your C program. In fact, independent
one review of various freely available interpreters posted on comp.lang.misc
mentioned that S-Lang was the easiest to embed (the review compared perl,
elisp, python. tcl, and S-Lang).
You can get S-Lang via anonymous ftp from amy.tch.harvard.edu in pub/slang.
Alternatively, S-Lang comes bundled as part of the JED editor distribution
which is in pub/jed. If you intend to incorporate S-Lang into your programs,
I encourage you to get the JED distribution since it is the largest program
available to embed S-Lang, including nearly 10,000 lines of S-Lang code, and
it makes a nice environment for developing S-Lang applications.
-- _____________ #___/John E. Davis\_________________________________________________________ # # internet: email@example.com # bitnet: davis@ohstpy # office: 617-735-6746 #