Scsh (a Unix Scheme shell) FAQ 
Author Message
 Scsh (a Unix Scheme shell) FAQ

Posted-By: auto-faq 3.3 (Perl 5.004)
Archive-name: unix-faq/shell/scsh-faq
Posting-Frequency: monthly
URL: http://www.*-*-*.com/ ~schinz/scsh-faq.html

Frequently Asked Questions
**************************

   This is the scsh Frequently Asked Questions list, version 2.14, 18
November 1999.

   This article is provided as is without any express or implied
warranties.  While every effort has been taken to ensure the accuracy of
the information contained in this article, the maintainer assumes no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein.

Meta-questions
**************

   This section contains questions and answers about this FAQ, its
author(s), etc.

What is the aim of this FAQ?
============================

   The aim of this FAQ is to provide some help and documentation to
people interested in scsh, a Unix shell that uses Scheme as its
scripting language.  It is mainly aimed towards those who do not know
much about scsh or Scheme.  This explains why some questions that might
seem trivial to the seasoned Scheme programmer are included anyway.

What was changed recently in this FAQ?
======================================

   Here is a list of recent changes.  The name of the person who
suggested the change (either explicitly by sending a mail, or
implicitly by posting in the newsgroup) is mentioned in parentheses.

  1. 1996/06/03 v1.0 Section about the incompatibilities between scsh
     and R4RS added; section about the module system added; some
     revamping; version bumped to 1.0 to celebrate our entry in the
     *.answers groups.

  2. 1996/06/06 v1.01 Some more revamping.

  3. 1996/06/14 v1.02 URL for Olin's home-page updated (Olin Shivers).

  4. 1996/06/17 v1.03 Small syntax error corrected (Geoffrey S. Knauth).

  5. 1996/06/19 v1.04 More syntax errors corrected (Yiorgos
     Adamopoulos).

  6. 1996/08/26 v1.05 Another batch of syntax errors corrected, Evelyn
     Mitchell mentioned as working on the reference card (Evelyn
     Mitchell).  Mention to RScheme added.

  7. 1996/10/28 v1.06 Reference to the texinfo version of the R4RS
     added.

  8. 1996/11/04 v1.07 FAQ updated for scsh 0.4.4.

  9. 1996/11/15 v1.08 Mention to Mzscheme added, section about porting
     scsh updated (Steven Jenkins and Brian Carlstrom).

 10. 1996/11/22 v1.09 Location of Scheme 48 v0.46 added (Richard
     Kelsey).

 11. 1997/04/29 v1.10 FAQ updated for scsh 0.5.0.

 12. 1997/05/01 v1.11 Section about contributing code updated (Olin
     Shivers), clarification about licensing terms added (Richard
     Kelsey), all URLs checked.

 13. 1997/06/09 v1.12 FAQ slightly updated for scsh 0.5.1.  Old
     FAQ-managment Perl scripts finally rewritten with scsh, now much
     less buggy (the links in the HTML version should now all be
     clickable).

 14. 1997/06/30 v1.13 Tomas By's initialization file for SLIB mentioned
     (Tomas By).

 15. 1997/07/28 v1.14 Minor syntactic changes (Paul-Jean Cagnard), URL
     for the FAQ updated.

 16. 1998/02/04 v1.15 URL for RScheme updated (Francis Puech)

 17. 1998/02/25 v1.16 Partial Guile implementation of scsh mentioned
     (Dave Love), HTML version of R4RS mentioned (Ray Dillinger), FAQ
     history (this section) trimmed a bit.

 18. 1998/04/12 v1.17 FAQ finally updated for R5RS, second edition of
     SaIoCP mentioned.

 19. 1998/12/29 v2.0 Debian scsh package mentioned (Eric Marsden), all
     URLs updated, section about Linux compilation problems added, new
     home-page for the FAQ mentioned, many small changes.

 20. 1999/02/12 v2.01 Minor error corrected (Bengt Kleberg)

 21. 1999/07/05 v2.10 Section about FreeBSD package added (Martin
     Cracauer)

 22. 1999/07/21 v2.11 E-mail address for FAQ maintainer updated.

 23. 1999/09/08 v2.12 Regular expression syntax described (Allyn
     Dimock), e-mail addresses for the mailing-list updated (Brian
     Carlstrom)

 24. 1999/09/27 v2.13 Additions to contrib/.

 25. 1999/10/07 v2.14 scsh version 0.5.2 released.

 26. 1999/11/15 v2.15 corrections: win32 support, SREs, corrected Scsh
     URL, new licence, link schemers.org.

Where do I get the latest version of this FAQ?
==============================================

   The latest version of the FAQ can be found at the "scsh FAQ
home-page":
  http://www.*-*-*.com/ ~schinz/scsh-faq.html

   This home-page contains three versions of this FAQ: an ASCII
version, an HTML version and an Info version.  If you have access to
the World Wide Web, I strongly recommend that you get the HTML version,
since all the hyperlinks can be followed just by clicking on them.

   Apart from that, this document is posted on the 13th of each month in
the newsgroups `comp.lang.scheme.scsh', `comp.lang.scheme',
`comp.unix.shell', `comp.answers' and `news.answers'.

Where do I send comments about this FAQ?
========================================

   Comments about this FAQ should be sent to the following address:

   Please help us in producing a useful document by sending suggestions
and material for this FAQ.  If you find stylistic, grammatical or syntax
errors, please also report them.

General
*******

   This section contains general questions about scsh: what it is,
where to find it, etc.

What is scsh?
=============

   Scsh is a Scheme shell.  That is, it is a Unix shell which uses
Scheme as its scripting language.  It was designed and written by Olin
Shivers and Brian Carlstrom, and is built on top of Scheme 48, an
implementation of Scheme written by Jonathan Rees and Richard Kelsey.

   Scsh currently includes the following features:

   - A complete Posix interface.

   - A very complete support for networking, with high and low level
     interfaces.  An additional network package, including an HTTP
     server, SMTP support, etc. is also available separately.

   - Powerful string manipulation functions: pattern matching, file-name
     manipulations, etc.

   - AWK-like macros.

   - An s-expression-based notation for regular expressions (SREs).

   However, it is currently aimed primarily at scripting use, rather
than interactive use (*Note Interactive scsh::).

How do you pronounce scsh?
==========================

   According to Olin, scsh is pronounced "skishhhh" (it rhymes with
"fish").

What is the current version of scsh?
====================================

   The current version (as of 18 November 1999) is 0.5.2.

What are the licensing terms for scsh?
======================================

   Scsh is *not* distributed according to the GPL (General Public
License) or some other well known license.  The licence changed in
v0.5.2 to become less restrictive.  Here are the exact terms, which can
be found in the file `COPYING':

     Copyright (c) 1993-1999 Richard Kelsey and Jonathan Rees Copyright
     (c) 1994-1999 by Olin Shivers and Brian D. Carlstrom.  All rights
     reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met: 1. Redistributions of source code must retain the above
     copyright    notice, this list of conditions and the following
     disclaimer.  2. Redistributions in binary form must reproduce the
     above copyright    notice, this list of conditions and the
     following disclaimer in the    documentation and/or other
     materials provided with the distribution.  3. The name of the
     authors may not be used to endorse or promote products    derived
     from this software without specific prior written permission.

     THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR
     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

What is Scheme?
===============

   Scheme is a small and elegant programming language of the Lisp
family, originally designed by Guy Lewis Steele Jr. and Gerald Jay
Sussman.  It includes powerful features like first-class procedures and
continuations, and is statically scoped (like Pascal).  For more
information, refer to the Scheme FAQ (*Note Getting the docs::).

What is Scheme 48?
==================

   Scheme 48 is a small and portable Scheme implementation written by
Jonathan Rees and Richard Kelsey.  It is based on a virtual machine
architecture (i.e. it does not compile to native code).

   Scheme 48 implements all the features described in R5RS (*Note
Getting the docs::) and some extensions like exceptions and a module
system.

How does scsh compare to other scripting languages, like Perl?
==============================================================

   It is always hard to compare programming languages objectively.
However, here are the main differences between scsh and its "rivals"
(both positive and negative differences are included):

   - Scsh is based on a well-designed and general programming language
     (Scheme) that has been developed over many years.  Thus, scsh is a
     general programming tool, not a quickly hacked tool with limited
     applications.

     Among other things, Scheme (and thus scsh) has serious data
     structures, not just strings like many scripting languages.  It
     also has powerful control structures like continuations and, in
     the case of Scheme 48, exceptions.

   - The interface to Unix functions has been well designed: the names
     are consistent, and their behavior is "Scheme-like".  For example,
     system calls do not use the `errno' global variables to signal
     errors, but raise exceptions instead.

     This approach is fundamentally different from, say, the Perl
     approach, where functions have the same name (often cryptic) and
     behavior (often strange) as their Unix equivalents.

   - Scsh is somewhat slow, especially on startup.  The new static
     linker (introduced with v0.4.3) can however be used to solve the
     slow-startup problem, at the expense of higher disk consumption.

Where can I get scsh?
=====================

   The latest version of scsh should be available at the following
locations:
 ftp://ftp-swiss.ai.mit.edu/pub/su/scsh/scsh.tar.gz  and
  http://www.*-*-*.com/

   The official scsh home-page is located at:
  http://www.*-*-*.com/

Where can I find documentation about scsh?
==========================================

   The main documentation about scsh is the scsh manual.  It is
included in the distribution: the ready-to-print postscript is in
`doc/scsh-manual.ps' and the{*filter*}source in `doc/scsh-manual'.
Moreover, a copy of the PostScript file is available at:
 ftp://ftp-swiss.ai.mit.edu/pub/su/scsh/scsh-manual.ps

   You may also want to take a look at the technical report describing
the design of scsh.  It is also included in the distribution
(`doc/scsh-paper.ps'), and a copy can be found at:
 ftp://ftp-swiss.ai.mit.edu/pub/su/scsh/scsh-paper.ps .


about using scsh, and especially the HTTP server that may be worth
reading. These notes can be found at:
  http://www.*-*-*.com/ ~shriram/Notes/Scsh/

   The documentation about Scheme 48 is also worth reading.  The user's
guide is in the file `doc/user-guide.txt' and the documentation about
the module system in `doc/module.ps'.  These two documents are also
available online, thanks to Margaret Fleck:
  http://www.*-*-*.com/ ~fleck/envision/scheme48/user-guide.html

   Also, since scsh is written on top of a Scheme system, you have
access to the great power of Scheme.  However, no Scheme documentation
is available with scsh, so you may wish to obtain the standard Scheme
references as well.  Here are some useful pointers:

   - The Scheme FAQ is maintained by Mark Kantrowitz and Barry Margolin
     and is available at:

      http://www.*-*-*.com/
   - The Scheme home-page is located at:
      http://www.*-*-*.com/

   - Schemers.org (` http://www.*-*-*.com/ ') is a collection of Scheme
     resources maintained by the Programming Languages Team at Rice
     University.

   - The official specification for Scheme is "The Revised^5 Report on
     the Algorithmic Language Scheme", often abbreviated R5RS.  This is
     the document you should use to look up details about Scheme.
     PostScript, HTML and info versions of this document are available
     in the directory:
      http://www.*-*-*.com/

   - There are many good books about Scheme, for example: "Structure and
     Interpretation of Computer Programs" (2nd ed.) by Harold Abelson
     and Gerald Jay Sussman, MIT Press, 1996 or "Scheme and the Art of
     Programming" by George Springer and Daniel P. Friedman, MIT Press,
     1989.  For more references, see the Scheme FAQ.

   - The Scheme 48 home-page is located at
      http://www.*-*-*.com/ ~jar/s48.html
     It contains useful information about Scheme 48, including papers
     describing its implementation. It is a little out of date however,
     and more recent information about Scheme 48 can be found on
     Richard Kelsey's page:
      http://www.*-*-*.com/
   The home-pages of the various people involved in the design of
Scheme, Scheme 48 or scsh may also be of interest to you.  Here are
some links:

   - Gerald Jay Sussman:
      http://www.*-*-*.com/ ~gjs/gjs.html

   - Jonathan A. Rees:
      http://www.*-*-*.com/ ~jar/jar.html

   - Richard Kelsey:
      http://www.*-*-*.com/

   - Olin Shivers:
      http://www.*-*-*.com/

   - Brian D. Carlstrom:
      http://www.*-*-*.com/ ~bdc/

Is there some kind of reference card for scsh?
==============================================

   Not exactly.  There is a small list of all of scsh's functions in
the file `doc/cheat.txt'.  However, it would be great to have a nice
TeXified reference card, which would include R5RS functions as well
(you know, something like the great Perl reference card).

Which newsgroups and mailing-lists are related to scsh?
=======================================================

   Currently, there is a mailing-list and a newsgroup which are
completely equivalent.

   The newsgroup used to be `alt.lang.scheme.scsh', but this has now
been replaced by `comp.lang.scheme.scsh'.  Please don't use the old alt
group, even if it still exists at your site.

   To (un)subscribe to the mailing-list, send a message to


   Also, `comp.lang.scheme', which talks about Scheme in general, may
be of interest to you.

   And if Scheme is your first functional language, you might also want
to read `comp.lang.functional'.

Does scsh run on my system?
===========================

   Currently, scsh runs without modification on the following systems:
DEC Ultrix, Harris CXUX, HP-UX, IBM AIX, Linux (however, *Note Problems
with Linux::), FreeBSD (*Note Scsh on FreeBSD::), NetBSD, NeXTSTEP, SGI
IRIX, Solaris, SunOS and Win32. It should also run without too many
changes on other 32 bits UNIX platforms (for 64 bits platforms like
Digital Unix, *Note Porting scsh::)

Is scsh easy to port?
=====================

   On 32 bits UNIX machines, yes, usually.  If your system isn't already
supported, take a look at the file `doc/install.txt' which contains
porting instructions.

   Porting scsh to 64 bits UNIX machines (or, more generally, non-32
bits machines) is currently harder. The main reason is that this
requires modifications to the Scheme 48 virtual machine (VM). This VM
is written in PreScheme, a dialect of Scheme, and the PreScheme
compiler isn't distributed with scsh. It is, however, included in
standard Scheme 48 distributions, which are available on Richard
Kelsey's FTP site:
 ftp://ftp.nj.nec.com/pub/kelsey/
(you'll also find a paper about PreScheme there). Note that Scheme 48
v0.46, on which scsh is currently based, is *not* available anymore.

   In any case, never try to hack the C code generated by the PreScheme
compiler (file `scheme48vm.c'); this is ugly and you'll have to restart
from scratch for the next release of Scheme 48.

   Apart from the problems with the Scheme 48 VM, there are also some
problems with scsh: the current version contains C code that assumes
32-bitness.  This occurs mainly in the foreign-function interfaces (that
is, interface between Scheme and C), where integers are converted
between their Scheme and C representation.

   Since v0.5.2 there is also a port to Win32 which uses the cygwin32
toolkit (thanks to Brian Carlstrom).

Can I run scsh under some other Scheme implementation?
======================================================

   Currently, scsh is tightly bound to Scheme 48 because it uses two
non-standard features of Scheme 48: its module system and its foreign
function interface.  This does not mean that porting it to another
Scheme implementation is impossible, but it is certainly hard.

   Many alternatives to Scheme 48 would exist, but two of them are worth
mentioning:
  1. RScheme.  RScheme, developed at the University of Texas, Austin,
     also has a module system (apparently similar to Scheme 48's
     system) and a foreign function interface (FFI).  Moreover,
     RScheme's embryonic documentation says: "[...] we may port full
     scsh to RScheme".  Wait and see.  For more information on RScheme,
     see:
      http://www.*-*-*.com/

  2. Mzscheme.  Mzscheme, developed at Rice University, also has a
     module system and an FFI.  It comes with a nice programming
     environment, DrScheme, which includes an editor, a graphical
     stepper, debugging tools and more.  Steven Jenkins

     system, but he has stopped working on it now.  If you are
     interested in what he did, feel free to contact him.

     More information about Mzscheme can be found at:
      http://www.*-*-*.com/

Installing and using scsh
*************************

   Now that you have downloaded scsh, you might want to install and use
it.  Some help about this subject is provided here.

I cannot compile scsh with recent versions of Linux!
====================================================

   [Maintainer's note: any help with this section would be greatly
appreciated, since I do not have access to a Linux machine right now,
and thus haven't tried Debian's package.]

   There is indeed a problem with recent versions of Linux, because of

for a scsh package for Debian GNU/Linux, available at:
  http://www.*-*-*.com/
.

   This problem should be resolved with the release of version 0.5.2
(the release notes say "problems with the signal system blowing up
builds on some of the more obscure Unix systems have been fixed").

Is there a "port" of scsh for FreeBSD?
======================================

   Installing scsh on FreeBSD is best done by compiling FreeBSD's scsh
"port" (meaning the FreeBSD term of a port, which is an integrated
third-party package) or by getting a binary "package" from a FreeBSD
ftp server. The port's integration of scsh automatically takes care of
some compiling and installation issues, among them support for ELF
based FreeBSD systems (3.x and higher).

   The sources of the port are available here:
  http://www.*-*-*.com/ #scsh-0.5.1
and the binary packages for various FreeBSD versions are here:
 ftp://ftp.freebsd.org/pub/FreeBSD/3.2-RELEASE/packages/shells/scsh-0....
 ftp://ftp.freebsd.org/pub/FreeBSD/2.2.8-RELEASE/packages/shells/scsh-...
 ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-stable/packages/shells/scsh...
 ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/packages/shells/scs...

It looks like I do not have enough memory to compile scsh?!?
============================================================

   If you get errors like "not enough memory" when building scsh, you
may try to adjust the limits on memory usage imposed by your system.
To do this, you have to use the `ulimit' command under `sh' and
derivatives or the `unlimit' command under `csh' and derivatives
(`tcsh' and the like).  See the reference manual of your shell for more
information.

Is there some kind of "contributed code archive" for scsh?
==========================================================

   The following two sites may be of interest to you:

  1. The contributed code directory for scsh, which is located at
      ftp://ftp-swiss.ai.mit.edu/pub/scsh/contrib/
     Currently includes

       1. su-net, an extensible web server written by Olin Shivers with
          extensions by Michael Sperber;

       2. Functional Postscript, which provides a Scheme interface to
          the Postscript page description language;

       3. A text markup system by Scott Draves and Jonathan Rees;

       4. pgscsh, a socket-level interface to the PostgreSQL
          object-relational DBMS, by Eric Marsden.

     Go on and send more code.

  2. The various Scheme code repositories, which are all listed in the
     Scheme FAQ.  The two main repositories are the Scheme Repository
     at Indiana University:
      http://www.*-*-*.com/
     and the CMU AI Repository, Scheme Section (a.k.a. the CMU Scheme
     Repository):
      http://www.*-*-*.com/

   Also, some useful code is included with Scheme 48 (hash tables
support, sorting functions, etc.) in the Big Scheme module.  Please
notice that you will have to open the module before being able to
access its functions.  For additional information, check the file
`doc/big-scheme.txt' in the scsh distribution.

   If you want to contribute some code, you should send it directly to

tar file.

   If you want to write some code for scsh but you don't know what, you
might want to take a look at the scsh home-page (*Note Getting scsh::)
which contains a list of interesting projects.

Can I use "plain" Scheme code with scsh?
========================================

   Generally speaking, all of the existing Scheme code can be run
without problem with scsh.  There is only *one* possibly annoying
incompatibility between R5RS-compliant interpreters and scsh: Symbols in
scsh are case-sensitive while this is not true for R5RS-compliant
interpreters.  This means, for example, that the following expression:

     (eq? 'symbol 'Symbol)

evaluates to `#t' with an R5RS-compliant interpreter (including the
original Scheme 48), while it evaluates to `#f' with scsh.

   In practice this shouldn't be a big problem, but if you encounter
code that works perfectly with all Scheme interpreters except scsh, then
this may be the reason.

   If you want to know the design decision behind this choice, you
should read the technical report describing the design of scsh (*Note
Getting the docs::).

   There are also other extensions to R5RS in scsh (e.g. C-like escaped
characters in strings) but they shouldn't break existing Scheme code;
you should have them in mind, however, when trying to write portable
Scheme code under scsh.

Can I use scsh as an interactive shell?
=======================================

   Well, technically you can: just run the "scsh" command and you will
enter a Scheme 48 session with all scsh functions available.  However,
this is definitely not suitable for interactive work: there is no
command-line editing, no command-line history, no file/function name
completion, no terse syntax, etc.  All these features are planned, and
Olin has a design for much of them.  However, nobody found the time to
implement them yet.

   In the meantime, a nice solution is to use a separate tool which
provides some of these features.  Here is a partial list of such tools:

  1. Emacs: use the `cmuscheme' package, written by Olin.  It is now
     part of Emacs, but if you don't have it on your system, you may
     use the one provided with scsh, which is also a little more
     up-to-date (check the directory `emacs').  This mode enables you
     to run scsh (or any Scheme interpreter by the way) as an inferior
     process.  It provides command-line editing, command-line history,
     dynamic completion, file-name completion, automatic indentation of
     Scheme code and more.

     If you want to give it a try right now, just type `C-u M-x
     run-scheme', and then enter `scsh' at the prompt.

  2. Some terminal emulator that enables input (or output) editing.  An
     example is the 9term terminal emulator, inspired by the Plan 9
     terminal emulator.  Check out 9term's home-page at:
      http://www.*-*-*.com/ ~matty/9term/index.html

  3. Any text editor that can run a process in one of its windows.  An
     example is wily (although it is more than a text editor), inspired
     by Plan 9's ACME tool.  For more information:
      http://www.*-*-*.com/ ~gary/wily/

I get "undefined variable" errors when I try to use some functions?!?
=====================================================================

   If you get "undefined variable" errors when you use functions from
the big-scheme package or macros like `define-record', then maybe you
didn't open the appropriate packages.  To open them, there are two
solutions:

  1. use the `,open' command in interactive mode, or

  2. use Scheme 48's module system.

   The first solution is nice for interactive work, while the second is
the one to use for scripts.

   The documentation on Scheme 48 module system can be found in the file
`doc/module.ps'. Olin Shivers also posted a message with further
explanations to the scsh newsgroup, which is archived at
  http://www.*-*-*.com/

Can I use SLIB (a Scheme library) with scsh?
============================================

   Yes, provided that you get (or write) an initialization file for
scsh.  Tomas By wrote one that you can get there:
 ftp://ftp.dcs.shef.ac.uk/home/tomas/scsh.init

   By the way, more information about SLIB is available by following
this URL:
  http://www.*-*-*.com/ ~jaffer/SLIB.html

Some basic IO functions (like EOF testing) seem not available in scsh?!?
========================================================================

   Don't forget that scsh is built on top of Scheme.  Therefore, you
have access to the full power of Scheme in scsh, and that includes some
basic IO functions, like the test for EOF, etc.  However, these
functions are not documented in the scsh manual, but in the official
Scheme specification (R5RS, *Note Getting the docs::).

How can I return the eof-object?
================================

   Some functions and macros (like the nice AWK macro) take a reader
function as an argument.  This reader function is required to return the
eof-object at the end of the input.  This is easy when the input is a
port, but much harder when the input is something else (like a list of
lines, etc.).  The reason is that R5RS specifies that the eof-object
can't be read by the `read' procedure, and therefore can't be included
literally in your source.  However, it can be defined like that:

     (define eof-object (read (make-string-input-port "")))

Is there support for protocols like HTTP, SMTP, etc.?
=====================================================

   Yes, but it isn't included in the scsh distribution.  You will find
it in the contributed code directory for scsh:
 ftp://ftp-swiss.ai.mit.edu/pub/scsh/contrib/net/

I get strange errors with some network functions?!?
===================================================

   If you are using scsh 0.4.2 under Solaris 2 or Irix 5, and the errors
you get look like:

     Error: 122
            "Operation not supported on transport endpoint"
            #{Procedure 9398 %listen}

then you should switch to a newer version of scsh: this was a known bug
of scsh 0.4.2.

   If, for some reason, you want to stick with v0.4.2, here is how to
fix the bug:

   In scsh's distribution directory, edit the file
`scsh/solaris/netconst.scm' (if you are under Solaris 2 and above) or
`scsh/irix/netconst.scm' (if you are under Irix 5 and above) so that
the following lines:

     (define socket-type/stream 1)              ; stream socket
     (define socket-type/datagram 2)            ; datagram socket
     (define socket-type/raw 3)         ; raw-protocol interface
     ;;(define socket-type/rdm 4)               ; reliably-delivered message
     ;;(define socket-type/seqpacket 5)      ; sequenced packet stream

are replaced by the following lines:

     (define socket-type/stream 2)              ; stream socket
     (define socket-type/datagram 1)            ; datagram socket
     (define socket-type/raw 4)         ; raw-protocol interface
     ;;(define socket-type/rdm 5)               ; reliably-delivered message
     ;;(define socket-type/seqpacket 6)      ; sequenced packet stream

then recompile scsh, by running make in the main directory, and
reinstall it.

How do I get the multiple values returned by a function?
========================================================

   This is documented in the R5RS.  However, with all these
continuations, the documentation might be a little hard to understand
for newcomers.  So here is a little (although not very useful) example
that uses `values' and `call-with-values':

     (call-with-values (lambda () (values 6 7)) *)
       => 42

   As you can see, the first argument to `call-with-values' is a
procedure which return multiple values, and the second is a procedure
which gets these multiple values as arguments.

   Scheme 48 provides another syntax to access multiple values: the
`receive' macro.  This macro binds multiple values returned by an
expression to variables, and then evaluates a sequence of expressions
with these bindings active (for Common Lisp fans, this is similar to
`multiple-value-bind').  Here is the above example, rewritten using
`receive':

     (receive (x y) (values 6 7) (* x y))
       => 42

   For more information on this function, check out
`doc/big-scheme.txt'.

   While this may not be evident here, the `receive' macro is often
easier to use than `call-with-values'.

How do I interface scsh with a C function?
==========================================

   You should use the `cig' program, written by Olin Shivers.  It is a
nice C interface generator.  The program and its documentation are
included in the `cig' directory.

   If you need examples on how to use `cig', just check out the scsh
source.

What is the syntax of regular expressions?
==========================================

   Scsh 0.5.2 introduced support for SREs, or Structural Regular
Expressions.  These provide an s-expression notation for building up
and operating on regular expressions. See the SRE section of the manual
for further details.

   Standard string-based regexps are also available (and in fact SREs
compile to string-based regexps). Henry Spencer's POSIX regular
expression engine is used to implement the matching. The syntax
accepted by this engine is described in its man page, which is
partially reproduced here:

     Regular expression syntax

     A regular expression is zero or more branches, separated by `|'. It
     matches anything that matches one of the branches.

     A branch is zero or more pieces, concatenated. It matches a match
     for the first, followed by a match for the second, etc.

     A piece is an atom possibly followed by `*', `+', or `?'.  An atom
     followed by `*' matches a sequence of 0 or more matches of the
     atom. An atom followed by `+' matches a sequence of 1 or more
     matches of the atom. An atom followed by `?' matches a match of
     the atom, or the null string.

     An atom is a regular expression in parentheses (matching a match
     for the regular expression), a range (see below), `.'  (matching
     any single character), `^' (matching the null string at the
     beginning of the input string), `$' (matching the null string at
     the end of the input string), a `\' followed by a single character
     (matching that character), or a single character with no other
     significance (matching that character).

     A range is a sequence of characters enclosed in `[]'. It normally
     matches any single character from the sequence. If the sequence
     begins with `^', it matches any single character not from the rest
     of the sequence. If two characters in the sequence are separated
     by `-', this is shorthand for the full list of ASCII characters
     between them (e.g. `[0-9]' matches any decimal digit). To include
     a literal `]' in the sequence, make it the first character
     (following a possible `^'). To include a literal `-', make it the
     first or last character.



Mon, 01 Jul 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Scsh (a Unix Scheme shell) FAQ

2. Scsh (a Unix Scheme shell) FAQ

3. Scsh (a Unix Scheme shell) FAQ

4. Scsh (a Unix Scheme shell) FAQ

5. Scsh (a Unix Scheme shell) FAQ

6. Scsh (a Unix Scheme shell) FAQ

7. Scsh (a Unix Scheme shell) FAQ

8. Scsh (a Unix Scheme shell) FAQ

9. Scsh (a Unix Scheme shell) FAQ

10. Scsh (a Unix Scheme shell) FAQ

11. Scsh (a Unix Scheme shell) FAQ

12. Scsh (a Unix Scheme shell) FAQ

 

 
Powered by phpBB® Forum Software