Best way to write portable schema code?

In Common Lisp, I can conditionally exclude or include code for different implementations, for example:

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

That way, I can write portable code by isolating non-portable bits.

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

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

I know that I can wrap all possible non-portable code fragments in different procedures, and then install compatibility packages as follows:

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

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

Is this the only way to do this?

I would not try to make a fully portable application in Scheme, but it would be nice if I could run my programs in two or maybe three different implementations.

+4
source share
1 answer

conversation slides from Dorai Sitaram on this topic. Following the directions here may also help.

+2
source

All Articles