Reputation: 4735
I'm trying to write something that works in both DrRacket/plt-r5rs and Gambit/gsi.
The problem I'm having is that (load "foo.scm")
in Gambit does not load define-syntax
-blocks. Using (include "foo.scm")
in Gambit works, but of course results in a syntax error in DrRacket.
Is there any way to solve this so that I can write portable R5RS code?
Things I've tried:
(include "foo.scm")
to (load "foo.scm")
and vice versa. Problem: Illegal to redefine macros in Gambit.(if gambit ...)
. Problem: Illegal to put define inside if(unless inside another define).Upvotes: 3
Views: 716
Reputation: 31147
In case it helps: In Racket you can use include in r5rs files:
#lang r5rs
(#%require (only racket include))
(include "foo.scm")
If you define #%require
to do nothing in Gambit, then you can use the same source file in both implementations.
Upvotes: 3
Reputation: 223003
It's very hard to write a module that's compatible with both Gambit and Racket.
There are indeed ways you can test for a specific implementation and define things conditionally. There are, in fact, two systems for doing this: SRFI 0 and SRFI 7. Most implementations support one or the other. Not very many support both.
Gambit supports SRFI 0. Racket supports SRFI 7.
Upvotes: 2