Scheme, due to its minimalistic nature, has a deeply fragmented ecosystem. This means that any non-trivial program ultimately needs to depend on implementation-specific features. This page simply explains a few methods a Scheme hacker can rely on for writing portable Scheme programs, scripts and libraries.
As far as Scheme standards go, you have three choices: R5RS, R6RS and R7RS. (See the Bibliography for links to the standards.)
scmxlate
cond-expand
for platform-specific code
SRFI-0
is the first SRFI/,
describing a simple macro cond-expand
that expands
code at macro expansion time, based on symbols/keywords that
stand for features the implementation chooses to provide as a
guarantee of portability, (not unlike Common Lisp's
#+
/#-
read macros).
Consider the following (overly simplistic) example;
;;; We need procedures from SRFI-1.
(cond-expand
(srfi-1) ; We already have it!
((or gauche chicken-3 chicken-4)
(use srfi-1))
(chicken-5
(import srfi-1))
(guile
(use-modules (srfi srfi-1)))
(chibi
(import (srfi 1)))
(else
(display "SRFI-1 could not be loaded.")
(newline)
(exit)))
(display "SRFI-1 successfully loaded.")
(newline)
cond-expand
features across implementations