New version of C-like interpreter available ("John E. Davis")
Tue, 29 Mar 1994 00:52:48 GMT

          From comp.compilers

Related articles
New version of C-like interpreter available (1994-03-29)
| List of all articles for this month |

Newsgroups: comp.unix.programmer,comp.os.msdos.programmer,comp.compilers
From: ("John E. Davis")
Keywords: interpreter, available, FTP
Organization: "Dept. of Physics, The Ohio State University"
Date: Tue, 29 Mar 1994 00:52:48 GMT


      The latest version of my C-like interpreter S-Lang is available. UNIKE
ANY FEE OR ROYALTY. Details on where to ftp S-Lang from is presented

      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];
            return sum;

Unlike a lot 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 `'.
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", "");

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 `'.

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 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:
# bitnet: davis@ohstpy
# office: 617-735-6746

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.