Description
Woosh is a really useless attempt at building an object-oriented shell
during
just one afternoon while avoiding any real programming. The idea is
quite
simple:
- Directories are objects (at least if they have a link to their
class)
- Classes are directories and of course objects
- Methods are executables (scripts, programs whatever you like)
inside classes or objects
Great Features
- Dynamic binding ;-), i.e. if a method is not found in an object
or
in the class of an object the super-class hierarchy is searched (up to
Object)
- Automatic inheritance of methods added after derivating
- Automatic support for class methods and inner classes
- Complete type insensitivity ;-)
- Only one additional executable to mess up your $PREFIX/bin
- Classes and objects can be created everywhere
- Built-in persistence
Download
Please download the tar ball from the
sourceforge project page.
Install
Unpack the tar ball wherever you like. Just to be sure have a look at
install_woosh,
then call it with the directory prefix where you want to install woosh
as
an argument (e.g. 'install_woosh /usr/local' or 'install_woosh $HOME').
Be
sure to use
full path names otherwise it probably won't work
(woosh
relies heavily on absolute paths). Set the env variable O_BASE to the
directory
you called install_woosh with.
Now you have a working woosh system, consisting of the two classes
Object
and
Class (sitting in $PREFIX/lib/woosh) and a shell
script,
call (in $PREFIX/bin).
Usage
Calling Methods
The main functionality provided by woosh is a way to call methods on
objects.
This is provided by the script
call, which is used as follows:
> call object method [args...]
Where
object is a directory supporting the woosh notion of
objects
and
method is an executable lying either in the object itself
or in
one of the classes comprising its super-class hierarchy. Because
classes
themselves are objects class methods are just a natural extension of
this
structure.
Currently there are three pre-defined methods coming with woosh (all
defined
in Object):
- Derive new_class - Creates a new class new_class
being
a sub-class of $SELF. This method is provided for convenience only
(actually
it's quite easy to derive classes in woosh, you could do it by hand).
- Create new_object - Creates a new object of class $SELF.
- className - prints the name of the class $SELF belongs to.
Creating new classes
New classes can be created by calling
derive on a class object.
Note that all classes
lying in $O_BASE will be found automatically and don't need to be
pointed at explicitly.
derive takes one parameter which is the name of the new class.
Writing methods
Methods are just ordinary executables located in a way that they can be
detected by the
runtime system. Nevertheless there are some points to note:
- The working directory of the method will always be the directory
it was called from.
- The absolute paths of the object and all its classes (from top to
bottom) will be appended to the PATH environment variable.
- At the time the method is executed there are some environment
variables it can use:
- SELF
Contains the absolute path of the object. Note that for class
methods SELF of course points to the class object.
- CLASS
Contains the absolute path of the class object.
- METHOD
Contains the name of the method called (as it is seen by call).
Programming with woosh
- use Derive to create many new classes
- add some scripts or programs to those classes (by copying them
into
the class directories)
- perhaps add some constructors (don't forget to call Super Create)
- create many nice objects und use them
How it works
It's really simple:
Objects are directories containing a link ._ pointing at their class,
classes
are objects containing a link Super pointing at their super-class.
Everything
else is done by call. It basically adds all relevant directories in the
right
order to the path and then executes the method as an ordinary shell
command
with all remaining arguments in the command line.
Possible future work
- Currently there's no type conversion.
- Super calls only work for class methods.
- In order to be at least marginally useful there should of course
be
many more pre-defined methods and classes. Well, we'll see.
- I really like multiple inheritance.
- Another point I am thinking about is integrating the
'traditional'
part of the shell (i.e. 99,9999...% ;-) into woosh. If for example
'real'
woosh-objects are equivalent to Objective C-objects, then ordinary
files
could be seen as equivalent to traditional C-types (like int, float,
char...).
As a next step you could define a (somewhat java-like) class-hierarchy
wrapping
those simple types (using e.g. mime-types), define some type checking
(file)
and voila - you have an object oriented shell.
- Having arrived at this point and woosh having swept over the
world
and overtaken all known command-lines it would be only a minor step to
hard-code
it into all shells and thereby reach WORLD DOMINATION!
Well, probably I will be too lazy for this. Nevertheless, have fun with
woosh!