Ivory System Examples

All of the examples here are order scripts. They all similar in that each comprises a sequence of actions designed to set up an initial data store configuration.

Notes:

1. For syntactic convenience, multiple store definition commands may be grouped to avoid the need for each to be prefixed with def. e.g.

def {
<lhs> = <rhs>
...
}

There are two general transformations for these forms:

def .x = <expr> => addVar #x Root <expr>
def .x.<path> = <expr> => addVar #x (<path>) <expr>

where addVar is a method of the VarSet class.

2. Object constructors may be prefixed with a data store path.

.timerStore.Timer[period:5000, proc: (\timer::Timer -> show "Chime\n")]

is equivalent to:

Timer [period:5000, proc: (\timer::Timer -> show "Chime\n")] (.timerStore)

3. Unlike normal functional programming conventions, the : symbol is a binding operator.

p: <expr>
transforms to Bind #p <expr>
where <expr> has type Exp *

Square brackets are used for lists in the usual way, the constructor Cons currently has no operator or pattern form. Hopefully, a suitable symbol will be found at some stage.

For objects with built-in functionality (e.g. Timers and Sockets) a common approach is taken:

The rule ensures that relevant system events are monitored, and implements the dynamic semantics of the particular object type. In general, most operating system dependencies are handled entirely by built-in methods and are invisible to application scripts.

Finally, there is a common section:

   .startADSGroup = !RefList [.timerStore];
   .start = mapProcRefs (raiseEvent (StartEvent 0)) (.startADSGroup)

The purpose here is to raise an initial event to signal that the Ivory session has started. There should be an entry in .startADSGroup for each data store containing objects where an applied rule method has a StartEvent pattern.

When an Ivory session begins, the convention is that if there is a value named start in the root store, it is evaluated. In the example cases mapProcRefs is invoked to apply a common action:

raiseEvent (StartEvent 0)

to all of the objects in .startADSGroup.

:

home

Last update: 11 October, 2005