Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

S-Lang

From Wikipedia, the free encyclopedia
Software library and scripting language
S-Lang
S-Lang based editor,JED
DeveloperJohn E. Davis[1]
Stable release
2.3.3[2] Edit this on Wikidata / 5 August 2022
Written inS-Lang scripting language
Operating systemPOSIX
TypeWidget toolkit
LicenseGPL 2.0 or later[3]
Websitewww.jedsoft.org/slang/Edit this at Wikidata
Not to be confused withS (programming language).

TheS-Lang programminglibrary is a software library forUnix,Windows,VMS,OS/2, andmacOS. It provides routines for embedding aninterpreter for the S-Langscripting language, and components to facilitate the creation oftext-based applications.[4] The latter class of functions include routines for constructing and manipulating keymaps, an interactive line-editing facility, and both low- and high-level screen/terminal management functions. It isfree and open-source software released under theGNU General Public License.

Brief history

[edit]

The S-Lang programming library was started in 1992 by John E. Davis, considering that functions he wrote for a text editor might be useful in other programs.[5] The earliest version of the library contained input/output routines for interacting with computer terminals and an implementation of a simple stack-based interpreter with aPostScript-likesyntax that he developed for use in a scientific plotting program. TheJED text editor was the first program to both embed the interpreter and use the terminal I/O components of the library.

Interpreter

[edit]

The interpreter makes up most of the S-Lang library, and is also where most of the development takes place. Although the original syntax supported by the interpreter resembled PostScript, the syntax has evolved to be much more C-like, with added support forobject-oriented programming style constructs. As a reflection of Davis's background in physics and professional interest in scientific computing, the language natively supports many vectorizedarray-based operations similar toMATLAB andIDL.[6]

Until version 2.0, the interpreter was not a standalone program. Instead, Davis advocated embedding it into applications to make them extensible. Using the interpreter meant either embedding it in aC program, or using it in the context of another application (e.g., theJED editor). The S-Lang shell, slsh, was a demonstration program capable of little more than running scripts. Version 2.0, released in 2005, made slsh interactive, and it has evolved into an application in its own right, with a number of external modules for use by it. As such, it has become the S-Lang interpreter.

Screen management

[edit]

In the mid-1990s while porting thesc spreadsheet to the S-Lang library, Davis developed the library's screen management facility.[citation needed] This component was designed to optimize screen output (by minimizing the number of characters sent to the terminal), and provide a simple way to support a variety of terminals through an extra layer of abstraction between the application code and the terminal. Theslrn newsreader was the first application to make full use of this interface.[citation needed] Since then, a number of other programs (e.g.,Mutt[7]) have taken advantage of this feature of the library, and it has become arguably the most used aspect of the library, as this component is considered to be an alternative tocurses.[8][9] Since version 2.0, the screen management routines have had transparent support forUTF-8.

Example source code

[edit]
#! /usr/bin/env slsh% The program below solves the following problem:%    Sort an input file that consists of lines like this%%        var1=23 other=14 ditto=23 fred=2privatevariableKeys,Values;privatedefinesort_fun(i,j){variables,a,b;s=Values[i]-Values[j];!if(s)returnstrcmp(Keys[i],Keys[j]);returns;}defineslsh_main(){variableline,len,i,vals;foreachline(stdin){% Split string into an array of strings %% by using white chars and = as delimite%line=strtok(line," \t\n=");len=length(line)/2;if(len==0)continue;% Even elements are keys, odd are values% The [0::2] is an array containing indexes with a 2 specifying step% and creating indexes from 0 to the length(line)Keys=line[[0::2]];vals=line[[1::2]];% The variable is declared aboveValues=atoi(vals);i=array_sort([0:len-1],&sort_fun);% There are different ways of writing the result.  Here is a% fast way that avoids a loop.% The empty parenthesis () denote variable declaration and specifies% that return value should be discarded()=printf("%s\n",strjoin(Keys[i]+"="+vals[i]," "));}}

See also

[edit]

References

[edit]
  1. ^Davis, John (26 November 2017)."A little bit about me".John E. Davis Software. Archived fromthe original on 1 June 2020. Retrieved1 June 2020.
  2. ^"slang releases".
  3. ^Davis, John (4 March 2018)."S-Lang Software License Information".John E. Davis Software. Archived fromthe original on 1 June 2020. Retrieved31 May 2020.
  4. ^Linux Bible 2010 Edition: Boot Up to Ubuntu, Fedora, KNOPPIX, Debian, openSUSE, and 13 Other Distributions, by Christopher Negus,Wiley, 2009,ISBN 978-0-470-48505-7, p.775
  5. ^"A Brief History of S-Lang". RetrievedJune 6, 2017.
  6. ^Getting more from your multicore: exploiting OpenMP from an open-source numerical scripting language, Noble, M. S., Concurrency and Computation: Practice and ExperienceVolume 20, Issue 16, pages 1877–1891, 2008, doi: 10.1002/cpe.1296
  7. ^"Mutt install guide". Retrieved2015-10-04.
  8. ^MySQL Developer's Library, by Paul Dubois, Pearson Education, 2009,ISBN 9780672329388, section 6.1
  9. ^Linux application development, by Michael K. Johnson and Erik W. Troan, Addison-Wesley, 2005,ISBN 9780321219145, p513

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=S-Lang&oldid=1338760895"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp