This directory contains some example GNU Smalltalk programs.
The programs are:
bench.st An extraordinarily precise low-level benchmark for Smalltalk,
by His Majesty contributed by Dwight Hughes and originarily prepared for
Dan Ingalls! Squeak. It executes two pieces of code and deduces the
system's speed in terms of bytecodes/second on bytecode-heavy
code (arithmetics - sieve in this case) and sends/second on
send-heavy code (a recursive Fibonacci computation in this
case) -- they usually coincide to two digits with the speeds
given by the GST runtime!
CairoBlit.st A simple example of the Cairo and SDL bindings.
Case.st A nice object for C-switch like behavior. Although it is slower
by Ulf than compiler-optimized ifs, try it: it really works nice.
CStream.st A stream providing functionality for writing C code.
Dinner.st The classic dining philosophers problem. You need working
by me Delays to try this (alarm is not very good but maybe it works).
Try `(Philosophers new: 5) dine'.
EditStream.st A stream handling fast insertions, using a double buffer
by Ulf with a gap between the buffers.
LazyCollection.st Implementation of #collect:, #select:, #reject: that do not
by me create a new collection unless really necessary.
Sync.st Many kinds of synchronization devices.
GenClasses.st Provides help in creating many similarly named classes.
Lisp.st A nice Lisp interpreter class; try "LispInterpreter
by Aoki Atsushi exampleXX" with XX going from 01 to 18. I modified it
Nishihara Satoshi to remove the Smalltalk-subset compiler that was needed
on proprietary systems that don't allow a compiler
to be enclosed in a run-time image -- it was 25%
of the total code; this way there is more focus
on the Lisp stuff.
MemUsage.st This is really more of a test suite kind of program. It
by sbb iterates through all the objects in the system, counting
up how much storage has been used by each, and printing a
total at the end. It has found more bugs in the memory
management system than I (sbb) care to admit.
Methods.st Examples of subclassing CompiledMethod... 'nuff said!
by Ian Piumarta
MiniDebugger.st A simplified debugger which shows how to use the single step
by me primitives to implement an interface that vaguely resembles
PackageBuilder.st A simple script to make package.xml file from a Smalltalk
by Stefan Schmiedl description. You may find it useful!
Prolog.st This is absolutely stunning! A Prolog interpreter written in
by Aoki Atsushi Smalltalk, from the same author as the Lisp interpreter; try
Nishihara Satoshi PrologInterpreter exampleXX with XX going from 01 to
PrtHier.st prints out the class hierarchy, indented according to
by sbb the number of super classes a class has.
Publish.st An object-oriented, multiple format class file-out system.
by me/sbb Currently includes Postscript for file-outs, and HTML/Texinfo
for documentation -- by the way, this example is used by the
makefile for GNU Smalltalk's info files. And also an example
PushBack.st A Stream with unlimited push-back capabilities. Together with
by sbb Tokenizer.st, it is used in many places (C interface, compiler)
Queens.st An elegant solution of the queens and amazons problem (amazons
by me can move like either the queen or the knight). There are:
2 solutions (1 discarding rotations/reflections) on a 4x4 board
92 solutions (12) on a 8x8 board
no solutions (!) to the amazons problem on a 8x8 board
4 solutions (1) to the amazons problem on a 10x10 board
A few examples usages are at the end of the file.
Richards.st The Richards benchmark (a simulation of an operating systems)
by unknown under Smalltalk, a classic in Smalltalk benchmarking because of
its use of polymorphism and OO.
shell An example of how to make a Smalltalk script work both if you
by Alexander file it in from GNU Smalltalk and if you launch it from the
Lazarevic shell; for it to work, the gst executable must be in the path.
If it is not, just do PATH=$PATH:<gst path> before running it.
SortCriter.st A very nice object that allows you to easily create
by Peter SortedCollections sorted using complex objects (specifying
William Lount which fields are more important and which must be sorted in
Tokenizer.st An abstract base class for lexical analyzers.
TokenStream.st Formerly a part of the class hierarchy. Now replaced with
by sbb CharacterArray>>#subStrings.
Generator.st Python/Ruby-like generators, using continuations.
Gen2.st Same, using contexts (slower).
Gen3.st Same, using processes (in the middle).
The directory also contains some bindings for external libraries; currently
these are GDBM, ZLib and MD5 bindings.
The directory also contains two examples of using Blox:
Man.st Man page viewer widget (example of using BExtended). To test
by me it evaluate "ManViewer openOn: 'path' ".
Tetris.st A Tetris game written using BLOX. To start it, use
by me "Tetris play". Cursor keys move the piece, Up rotates it,
Return drops it.
More examples can be found in the blox/BloxExtend.st and blox/test.st file
In addition, this directory contains two scripts that can help converting
from other Smalltalk source code formats to the traditional file in (chunk)
format. These are:
- `pepe.sed', that converts from the Pepe format, a portable format consisting
exclusively of executable code (an example is in tests/ansi/ansi.pepe; this
script can be slow.
- `xml.sed', that converts from an XML DTD designed for Smalltalk source. This
script does not convert `statics' (that's how the DTD calls class variables)
yet. Requires GNU sed.
The `unsupported/misc' directory contains some other small example GNU
Smalltalk programs which test more advanced aspects of Smalltalk, either
various packages or the VM. Among others, `torture.st' is Andreas Klimas'
nice memory torture test program - like MemUsage.st it has found more bugs
in the memory management system than I care to admit...