Go to the previous, next section.

Using ILU with Scheme (Guile)

Introduction

This document is for the Scheme programmer who wishes to use ILU. The following sections will show how ILU is mapped into Scheme constructs and how both Scheme clients and servers are generated and built.

The Scheme support in ILU was kindly donated by
Siemens Corporate Research Inc., and written by Bill Nell.

The ISL Mapping to Scheme

Names

The mapping of ISL names to Scheme names for objects and methods are described in the following sections. For all other ISL types and exceptions the Scheme name will be module-name:name.

Basic Types

This section describes the mapping of ISL types to Scheme types. Note that some mappings use extra precision where it is not necessary. This is because the Scheme types have no finer distinctions for these types. The basic ISL types have the following mapping to Scheme constructs:

Constant

Strings

Pickles and Typecodes

Not implemented yet.

Constructed Types

Enumeration

Implemented with a set of symbols bound to the integer values of the enumeration type.

Array

Arrays are implemented as Scheme vectors. For arrays, a Scheme function will be generated that takes no arguments and returns a vector with dimensions corresponding to the ISL array type. The user is responsible for setting elements in the vector.

Sequence

Sequences are implemented as lists, except for sequences of characters, which are implemented as strings.

Record

Each record is mapped to an ILU-YASOS object. Each object has a constructor named (make-module-name:record-name) that takes no arguments. Each object also has methods to get and set all the fields of that record. These accessors follow the pattern of (get-field-name obj) and (set-field-name obj value). In the future record constructors will be able to take arguments to initialize their fields.

Union

Unions are implemented as a cons'ed value, with the cdr containing the union type discriminant, and the cdr containing the actual value. For union types, a constructor function taking two arguments is created. The first argument is the discriminator and the second is the union value. The discriminator of a union can be accessed or set using the car and set-car! functions, respectively. The value of a union can be accessed or set using the cdr and set-cdr! functions, respectively.

Optional

Either #f or the value. Note that this mapping is broken for optional boolean types.

Object Types

Each object is mapped to an ILU-YASOS object.

Each object type has a constructor named (make-module-name:object-name) that takes no arguments. The user should not attempt to create objects using the constructor since these are surrogate objects and not true objects. All the method names should map exactly as they appear in the ISL definition.

Surrogate and True Object Types

Class: ilu:object

This is the root class of all objects in the Scheme LSR. It provides some basic functionality required by all ILU objects. The public methods are described below. Since ILU-YASOS has no notion of public or private there are additional methods which are not described here and should not ever be called by the user.

Surrogate objects present an interface to access a true objects which may or may not live in the same address space as the surrogate object. The user is not allowed to create their own surrogate objects. They must be looked up using a name binding service or through the use if a string binding handle.

Behind every surrogate object there must be a true object. The user is in charge of defining true objects. Implementing a true object for a particular surrogate object is accomplished by subclassing the surrogate object class provided by the Scheme stubber. Each true object implementation must override every method of the surrogate "parent" object to work correctly. See the section on ILU-YASOS for implementing objects in Scheme. Also, see the examples of a Scheme client and server given in the examples/test1 directory.

IMPORTANT CAVEAT: When using multiple inheritance with ILU-YASOS objects to implement "true" objects it is important that the correct ILU class record be assigned to the true object. The class record of the last class listed in the superclass list of the object definition will be the one used for the object being defined. If this is not the desired class record, the implementor must set it by hand. (Hopefully, in the future this will be taken care of automatically). Usually, this is not a problem if you always place the most specific superclass of an object last in the list of superclasses.

Methods, Parameters, and Exceptions

All methods take at least two arguments in addition to any other arguments specified in the ISL definition. The first argument is the object the method is being called on and the second argument is the status object. The remaining arguments are the same as in the ISL definition.

Class: ilu:status

This is a status object type, used to record the success or failure of all method calls. Later this will be replaced with catch and throw. Also note that even though individual modules create their own status types, the ilu:status type can still be used in their place.

ilu:status objects support the following methods:

Normal methods are called in the following manner:
(method-name object status arguments)
If any errors are encountered while executing the method, they will be stored in the status object parameter. Failed method calls always return #f.

Arguments defined as "out" must still be passed as placeholders even though their values are ignored. The return values of methods are as follows: If the method has no "inout" or "out" parameters, a single value is returned. When a method has "inout" or "out" parameters the method returns a list of values which contains any "inout" and "out" values (in the order they are specified in the ISL definition) followed by the "normal" return value as the last element of the list.

All exceptions are raised by setting the return code of a status value to something other than ilu:success. Depending on the type of the exception there may also be additional data associated with it that can be set using the "set-status-value" method on a status object.

Asynchronous methods are available in the Scheme LSR. They will return immediatedly with a return value of #t.

Functional methods are currently not supported in the Scheme LSR. At the moment they are treated as normal method calls.

Garbage Collection and COLLECTIBLE

At the moment garbage collection of surrogate and true objects is not supported.

Access to standard ILU features

Servers and Ports

Object Tables

See ilu:create-object-table.

Threading and Event Loops

At the moment the Scheme LSR does not support threading, so only the event loop mode of operation will work.

Custom Records

String Binding Handle Formation

Simple Binding

Principal Identities and Passports

Building Scheme/ILU Applications

Initialization order

All object and type definitions are initialized automatically when loading the Scheme code for a particular interface. The (ilu:init) function is used to initialize the GC server and callback object. If the user wishes to select their own main loop object, they must register it before calling (ilu:init).

ILU-YASOS

The ILU version of YASOS is a slightly modified version of the standard YASOS with the following differences:

Where to get Guile 1.2 and SLIB

Guile 1.2.

SLIB 2b1.

Guile snapshots -- Guile snapshots are daily updates of the Guile system, use them at your own risk. Also some snapshots may not be compatible with the current implementation of the stubber and runtime.

See also the Report on the Algorithmic Language Scheme -- revision 4 and the SLIB Reference Manual.

Stub Generation

Implementing an ILU module in Scheme

Implementation Inheritance

Exporting Objects

Using an ILU module in Scheme

If you are using Guile Scheme, the value of the environment variable LD_LIBRARY_PATH should include the directory in which the ilu library for Guile has been installed; that's normally `ILUHOME/lib'. Additionally, the environment variable SCHEME_LOAD_PATH should contain `ILUHOME/guile', so that the ILU Guile files can be found.

Scheme/ILU API Reference

Go to the previous, next section.