Determining Scheme Implementation

Discussion of Scheme and Racket

Determining Scheme Implementation

Postby Will Donnelly » Sat Aug 30, 2008 2:38 pm

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?
Will Donnelly
 
Posts: 2
Joined: Sat Aug 30, 2008 2:08 pm

Re: Determining Scheme Implementation

Postby gcartier » Tue Sep 02, 2008 6:08 am

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 :

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))

Guillaume Cartier
gcartier
 
Posts: 4
Joined: Tue Sep 02, 2008 5:22 am


Return to Scheme

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron