Scsh as a scripting language
Scsh has a high-level process notation for doing shell-script like
tasks: running programs, establishing pipelines and I/O redirection.
For example, the shell pipeline
gunzip < paper.tex.gz | detex | spell | lpr -Ppulp &
would be written in scsh as
(& (| (gunzip) (detex) (spell) (lpr -Ppulp)) ; background a pipeline
(< paper.tex.gz)) ; with this redirection
Scsh embeds this process notation within a full Scheme implementation.
The process notation is realised as a set of macro definitions, and is
carefully designed to allow full integration with standard Scheme code.
Scsh isn't Scheme-like; it is Scheme. At the scripting level, scsh also
has an Awk design, also implemented as a macro
that can be embedded inside general Scheme code.
Scsh as a systems-programming language
Scsh additionally provides the low-level access to the operating
system normally associated with C. With the exception of signal handlers,
the current release provids full access to Posix, plus important non-Posix
extensions, such as complete sockets support. “Complete Posix” means: fork, exec & wait, sockets, full read, write,
open & close, seek & tell, complete file-system access, including stat,
chmod/chgrp/chown, symlink, FIFO & directory access, tty & pty support,
file locking, pipes, select, file-name pattern-matching, time & date,
environment variables, and more. In brief, you can now write Unix systems
programs in Scheme instead of C. For
example, we have implemented an extensible HTTP server at MIT entirely in
scsh. As important as full access to the OS is the manner in which it is
provided. Scsh integrates the OS support into Scheme in a manner which
respects the general structure of the language. The details of the
design are discussed in a joint MIT Lab for
Computer Science/University of Hong Kong technical report, “A Scheme shell,”
also to appear in a revised format in the Journal of Lisp and Symbolic
Computation. This paper is also available by ftp.
Scsh is a portable programming environment
Scsh is
designed for portability. It is implemented on top of Scheme 48, a
byte-code-interpreter Scheme implementation. The Scheme 48 virtual
machine can be compiled on any system with a C compiler; the rest of
Scheme 48 is machine-independent across 32-bit processors. Scsh's OS
interface is also quite portable, providing a consistent interface
across different Unix platforms. We currently have scsh
implementations for DEC Ultrix, GNU Hurd, HP-UX, IBM AIX Linux,
NetBSD/i386, NeXTSTEP, SGI IRIX, Solaris, and SunOS. Scsh code should
run without change across these systems. Porting to new platforms is
usually not difficult.
|