views:

162

answers:

1

In Common Lisp I can conditionally exclude or include code for different implementations like this:

#+sbcl (use-sbcl-cool-feature)
#-sbcl (use-my-own-not-so-cool-version)

This way I can write portable code by isolating the non-portable bits.

How can this be done in Scheme? Is there a way to ask the Scheme interpreter or compiler its name (or even which standard it implements) like this?

(cond ((r6rs?)
       (make-eq-hashtable))
      ((gambit?)
       (make-table))
      ;; other cases here
      (#t (make-my-inefficient-hash-table))

I know I could wrap all possible non-portable pieces of code in different procedures and then have compatibility packages like this:

;; in my-libs-gambit.scm:
(define make-hash-table make-table)

And simlarly for my-libs-[other-schemes-here].scm

Is that the only way to do it?

I wouldn't try to make a completely portable application in Scheme, but it would be nice if I could make my progams run in two or maybe three different implementations.

+2  A: 

Slides of a talk by Dorai Sitaram on this topic. Following the directions given here also might help.

Vijay Mathew
Thanks a lot Vijay! I'll lookinto scmxlate -- it seems to fit my needs nicely.
Jay