Determining Scheme Implementation
-
- Posts: 2
- Joined: Sat Aug 30, 2008 2:08 pm
Determining Scheme Implementation
I'm trying to implement a simple set of tools that I can use for to make my life easier when coding in Scheme. So far I have a 19 line module/object system and am writing a little unit test system. Unfortunately, after that I want to try to make a cross-implementation library that I can use for some system-related tasks (starting a program, communicating to it via unix stdin, etc). Most of the implementations I am interested in offer this sort of functionality, but the mechanisms differ. Is there any way that I could easily determine the Scheme implementation that my code is being run under so that I can write my code differently for each one, or will I have to end up doing something hackish and requiring that a value be set in the code?
Re: Determining Scheme Implementation
SRFI-0 http://srfi.schemers.org/srfi-0/ is what you are looking for.
The purpose of this SRFI was amongst other things to solve the problem you are facing. As far as I know, all major Scheme implementations implement this SRFI.
Here is sample usage for accessing global variables in Chicken and Gambit :
Guillaume Cartier
The purpose of this SRFI was amongst other things to solve the problem you are facing. As far as I know, all major Scheme implementations implement this SRFI.
Here is sample usage for accessing global variables in Chicken and Gambit :
Code: Select all
(cond-expand
(chicken
(require 'lolevel)
(define (global-variable? symbol)
(global-bound? symbol))
(define (global-value symbol)
(global-ref symbol)))
(gambit
(define (global-variable? symbol)
(and (##global-var? symbol)
(%%not (##unbound? (##global-var-ref symbol)))))
(define (global-value symbol)
(##global-var-ref symbol)))
(else))