Previous: , Up: iklib modules examples   [Index]


6.36.2.4 Utilities examples

The following example shows how syntactic abstractions can be used to access definitions in a module without explicitly using the import form:

(import (vicare))

(define-syntax in-module
  (syntax-rules ()
    ((_ ?module ?expr ...)
     (internal-body (import ?module) ?expr ...))))

(module red (one two)
  (define (one arg)   (cons 'red-one arg))
  (define (two arg)   (cons 'red-two arg)))

(module green (one two)
  (define (one arg)   (cons 'green-one arg))
  (define (two arg)   (cons 'green-two arg)))

(fprintf (current-error-port)
         "calling ones: ~s ~s\n"
         ((in-module red one)   123)
         ((in-module green one) 456))