S-Lang (programming language)

From Wikipedia, the free encyclopedia

S-Lang is an interpreted programming language designed by John E. Davis to provide extensibility to C-based applications in the form of an embedded interpreter. Created in 1992, its original syntax reflected its origins as a stack-oriented language, but the current syntax has evolved to more closely resemble that of C. S-Lang is small, simple, and dynamically typed, with strong support for numerical array-based operations. Because of its size and ease-of-embedding, S-Lang has been embedded in non-numerical programs such as the slrn newsreader and the JED text editor.

[edit] Example

Several aspects of the language are illustrated by the following example. These include support for array-based arithmetic, function qualifiers, and object-oriented style method calls. The example makes use of the Grace plotting module to plot an exponentially damped sine curve with overplotted points from a file:

    slsh> require ("grace");          % load the grace module
    slsh> g = grace_new ();           % create an instance of grace
    slsh> x = [0.01:10*PI:#1000];
    slsh> y = exp(-x)*sin(x);
    slsh> g.plot (x,y; logx);
    slsh> readascii("file.dat", &x, &y; cols=[1,3]); 
    slsh> g.oplot (x,y; color="red");

[edit] See also

[edit] External links

Languages