thor
thor

Reputation: 22560

How to "load" a file only once in scheme r5rs?

Is there a way to make sure that a scheme file (R5RS) is loaded only once?

That is, if foo.scm is loaded multiple times in bar.scm (directly or indirectly), make sure the content of foo.scm is only loaded the first time.

In C++, one can enclose the whole content of a source file in #ifndef like this to avoid repeated imports:

#ifndef _some_tag 
#define _some_tag

//...

#endif

Is there a similar way to ensure that an old R5RS file loads only once in a REPL session?

-- Clarification --

Thanks for the answers and comments so far, which suggest that there is no portable way of loading a file only once in R5RS.

Just to state the motivation, I was playing with the little prover code, which is R5RS. I found that loading its file j-bob.scm twice makes the REPL extremely slow. As pointed out in this bug/issue report, this is because j-bob redefines basic scheme keywords. Someone in that bug report suggested that a proper solution is to use r7rs (or r6rs) modules. Nonetheless, I was curious if this can be handled in r5rs. Hence this question.

Upvotes: 1

Views: 148

Answers (0)

Related Questions