A version of SILK with generic functions

SILK is a compact scheme dialect written in Java that can add powerful capabilites to Java applications, such as:

The original version of SILK was written by Peter Norvig. Tim Hickey added JLIB a system for easily writing applets.

Generic functions have been added to SILK. A paper (html version, Postscript version) describing them was presented at Reflection '99. You can also see a live demo of many of the examples presented in the talk.

An earlier version of SILK was described at the Lisp in the Main Stream conference, November 1998:

Running SILK

SILK and your application can have access to each other if they are in the same classpath, or more specifically, come from the same ClassLoader.

SILK's operation and capabiliies depened on which ClassLoader is used and how SILK is to run. See Example Scripts below. Either just grab the jar/scheme.jar, down load everything, or if you are at BBN, you can build SILK from CVS. Everything works in JDK 1.2. However most of SILK will run fine in JDK 1.1 either as an application or an applet. What doesn't currently work in JDK 1.1 is related to ClassLoaders, SWING graphics, and compiling from inside SILK.

A JDK 1.2 version of SILK is provided in jar/scheme.jar which also includes scheme software in *.scm files.with generic function extensions in src/generic. As the live demo demonstrates, this jar will also work in JDK 1.1, but some of the classes will not work.

You can build your own version using one of several tiny scripts:

Example Scripts

Here are some interesting variants to use or copy and customize:

Main classes

The two main classes of SILK are silk.Scheme and silk.EmbeddedScheme. Their main(String[] args) method treat the args as a set of files that are loaded. Then a read-eval-print loop is started. The class silk.EmbeddedScheme automatically load "src/generic/load.scm", while silk.Scheme does not. It also static methods that can be useful when SILK is used as part of an application.

File lookup

The file opening done command line processing, and by (open-input-file) and (load) has been generalized to allow relative file naming and use of URL's. This allows *.scm files to be added to a jar file without modification. The lookup strategy for finding a file named name is to try each of the following until one succeeds:
  1. Open the file name (application only).
  2. Prepend each of the elements of the list scheme.roots to name and open that file (application only).
  3. Use the classloader to open name as a resource, for example in a *.jar file.
  4. Open name as a URL.
  5. Open name relative to documentbase (applet only).
When silk.Scheme starts, it looks for a "scheme.eval" system property. The value of this property is evaluated just after the primitives are loaded. The primary purpose of this is to set the scheme.roots variable. So for example, the way i use it is:
java "-Dscheme.eval=(set! scheme.roots '(d:/java/elf d:/java/silk))" silk.EmbeddedScheme src/classgen/compile.scm ulps/jdbc.scm 
So, the file compile.scm is found in the scheme.jar and ulps/jdbc.scm is found relative to d:/java/elf.

Other information

API's:

Release notes

Halloween, 1999

Previous release notes.