Next: , Previous: , Up: Modules   [Contents][Index]

5.12.10 Module Limits

Mutual open is ok for ordinary use. Howevere, care is necessary if a module definition includes top-level calls. Look at this example:

;; file a.jl
(define-structure a
    (export aa)
    (open rep b)
  (define (aa)))
;; file b.jl
(define-structure b
    (open rep a)
;; From somewhere
(require 'a)  ⇒ error: (void-value aa)

Let’s see step by step. File “a.jl” is read from the top. It declares the symbol aa is exported. Next, it opens b. The module b opens a, i.e. if a symbol aa is found, its value will be refered to a. Finally, aa is evaluated. But its definition is not yet done, and it fails.

One solution is use of a hook; put the problematic evaluation into a hook, and call that hook later somewhere.