I have two r5rs files - scheme-interpreter.scm and scheme-interpreter-operations.scm. The first file contains two functions - interpret and evaluate. The second file contains auxilliary functions, which get called inside evaluate. However, these functions can call evaluate as well. Thus, recursion occurs. When I reference each file in the other one like this:
scheme-interpreter.scm:
(#%require "scheme-interpreter-operations.scm")
(#%provide (all-defined))
scheme-interpreter-operations.scm:
#lang r5rs
(#%require "scheme-interpreter-operations.scm")
(#%provide (all-defined))
I get errors. Is it possible to load files in a circular manner?
Using the Racket R5RS language with the racket module system on top like in your sample code, it's possible to have circular dependencies using using
lazy-require.Example:
s1.scm:
s2.scm:
And demonstration:
For a general R5RS approach, a
(load "s2.scm")in s1.scm works with Chicken, Guile and plt-r5rs, at least (With the Racket specific stuff removed, of course). Adjust filenames appropriately.