[plt-scheme] circular module dependency

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Wed Aug 11 08:21:20 EDT 2004

Hi,

There are two modules in my application which depend on each other.
Both of them are quite large, I was thinking to make one module but
they provide two different things. Basically they form a circular 
dependency. I cannot separate out the parts into a third module.
Guile and bigloo allowed me to do circular dependency, but 
plt-scheme does not. (So far the strictness of plt-scheme helped me
in the abstraction and dependency formulation, but now I am little
bit stuck.) At the moment I provide a setup function in one of the 
modules which must be called before any execution of the application.
This setup function sets an internal variable to a function from the other
module. I try to demonstrate it in pseude code:

(module selection mzscheme
  (provide setup-selection ...)

  (define view-func #f)

  (define (setup-selection func)
    (set! view-func func)
  )
  ...
  ; somewhere we call the view function
  (if (and view-func (procedure? view-func))
    (view-func)
  )
  ...
)

(module view mzscheme
  (require selection ...)
  (provide selection-view ...)
  ...
  ; body
)

And in my main
  (require selection view)
  (setup-selection selection-view)
  ; then start everything


Somehow I feel it a little bit fragile. Maybe I am a perfectionist. But
is there any better way to do this ? How can I make circular 
dependency in plt-scheme ? (Maybe I do not see the forest from the 
tree.)

Thanks for any advice.

Peter Ivanyi




Posted on the users mailing list.