Portable load / enable syntax definition in R5RS schema?

I am trying to write something that works both in DrRacket / plt-r5rs and in Gambit / gsi.

The problem I encountered is that (load "foo.scm")in Gambit it does not load define-syntax-blocks. Use (include "foo.scm")in Gambit works, but of course leads to a syntax error in DrRacket.

Is there any way to solve this problem to write portable R5RS code?

Things I tried:

  • Override (include "foo.scm")to (load "foo.scm")and vice versa. Problem: Invalid overriding macros in Gambit.
  • Wrapping specified overrides in (if gambit ...). Problem: It is incorrect to define inside if if (unless otherwise specified inside).
  • Pass a string with the file name to include in the library file. Problem: The inclusion in the Gambit seems to occur before the interpretation begins.
+3
source share
2 answers

It is very difficult to write a module compatible with both Gambit and Racket.

There are really ways you can test for a specific implementation and define things conditionally. There are two systems for this: SRFI 0 and SRFI 7 . Most implementations support this or that. Not as much support as.

Gambit supports SRFI 0. The racket supports SRFI 7.

+2
source

In case this helps: in Racket, you can use include in r5rs files:

#lang r5rs
(#%require (only racket include))
(include "foo.scm")

#%require, Gambit, .

+2

All Articles