Category:S-lang: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
No edit summary
Line 16: Line 16:
function. This is not part of S-Lang per se, but is normally
function. This is not part of S-Lang per se, but is normally
included in the S-Lang shell "slsh". If it is missing, or you're
included in the S-Lang shell "slsh". If it is missing, or you're
using some other S-Lang environment, options include a C-like
using some other S-Lang environment, options include C-like fputs(),
sprintf() and printf(). Their format and parameters work about
sprintf() and printf(). Their format and parameters work about
like you'd expect in a C-inspired interpreted language.
like you'd expect in a C-inspired interpreted language.
Line 22: Line 22:
<code>sprintf(f, d..)</code> [f=string format, d..=zero or more data items]
<code>sprintf(f, d..)</code> [f=string format, d..=zero or more data items]
returns a string. <code>printf(f, d..)</code> prints to "stdout" and returns
returns a string. <code>printf(f, d..)</code> prints to "stdout" and returns
the number of items formatted: remember S-Lang is a "stack
the number of items formatted. <code>fputs(s, fp)</code> prints string s to the
file-pointer fp and returns the string length or -1 on error. Remember S-Lang is a "stack
language", so even if you don't care about that number, your code
language", so even if you don't care about the return value, your code
should "eat" it:
should "eat" it:


() = printf("S-Lang: %d tasks and counting!\n", 17);
() = printf("S-Lang: %d tasks and counting!\n", 17);

() = fputs("foo\n", stdout);
S-Lang is the extension language for the lightweight Emacs-like
S-Lang is the extension language for the lightweight Emacs-like
[http://www.jedsoft.org/jed/ programmer's editor Jed]. There, the
[http://www.jedsoft.org/jed/ programmer's editor Jed]. There, the

Revision as of 18:50, 20 July 2016

This page is a stub. It needs more information! You can help Rosetta Code by filling it in!
Language
S-lang
This programming language may be used to instruct a computer to perform a task.
Official website
Type checking: Dynamic
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using S-lang.

S-Lang is a multi-platform programmer's library designed to allow a developer to create robust multi-platform software. It provides facilities required by interactive applications such as display/screen management, keyboard input, keymaps, and so on. The most exciting feature of the library is the slang interpreter that may be easily embedded into a program to make it extensible. While the emphasis has always been on the embedded nature of the interpreter, it may also be used in a stand-alone fashion through the use of slsh, which is part of the S-Lang distribution.

Unlike many interpreters, the S-Lang interpreter supports all of the native C integer types (signed and unsigned versions of char, short, int, long, and long long), and both single and double precision types, as well as a double precision complex type. Other data types supported by the interpreter include strings, lists, associative arrays (hashes), user-defined structures, and multi-dimensional arrays of any data-type.

The S-Lang interpreter has very strong support for array-based operations making it ideal for numerical applications. (from the official web site])


Task Output Notes:

For simplicity, many of the S-Lang tasks use the print() function. This is not part of S-Lang per se, but is normally included in the S-Lang shell "slsh". If it is missing, or you're using some other S-Lang environment, options include C-like fputs(), sprintf() and printf(). Their format and parameters work about like you'd expect in a C-inspired interpreted language.

sprintf(f, d..) [f=string format, d..=zero or more data items] returns a string. printf(f, d..) prints to "stdout" and returns the number of items formatted. fputs(s, fp) prints string s to the file-pointer fp and returns the string length or -1 on error. Remember S-Lang is a "stack language", so even if you don't care about the return value, your code should "eat" it:

   () = printf("S-Lang: %d tasks and counting!\n", 17);
   () = fputs("foo\n", stdout);

S-Lang is the extension language for the lightweight Emacs-like programmer's editor Jed. There, the output functions include:

   insert(s)       write string s into current buffer
   vinsert(f,d..)  insert(sprintf(f, d..)) ["variable"] equivalent
   
   message(s)      write string s into "mini-buffer"
   vmessage(f,d..) message(sprintf(f, d..)) equivalent
   
   error(s)        like message(), but in error-color, then cancel cmd
   verror(f, d..)  error(sprintf(f, d..)) equivalent

See Also

Wikipedia:S-Lang(programming language)