[previous] [up] [next]     [contents] [index]
Next: Linking Units and Creating Up: Invoking Units Previous: Invoking Units

Examples

These examples use the definitions from the earlier unit examples in section 7.1.1.

The f1@ unit is invoked with no imports:

  (invoke-unit f1@) ; displays and returns the current time

Here is one way to invoke the database@ unit:

  (invoke-unit database@ display)
This invocation links the imported variable message in database@ to the standard Scheme display procedure, sets up an empty database, and creates the procedures insert and lookup tied to this particular database. Since the last expression in the database@ unit is insert, the invoke-unit expression returns the insert procedure (without binding any top-level variables). The fact that insert and lookup are exported is irrelevant; exports are only used for linking.

Invoking the database@ unit directly in the above manner is actually useless. Although a program can insert information into the database, it cannot extract information since the lookup procedure is not accessible. The database@ unit becomes useful when it is linked with another unit in a compound-unit expression.



PLT