[plt-scheme] R5RS is totally useless for PLT, and I presume that R6RS is, also.

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Thu Nov 20 07:41:16 EST 2008

On Wed, 19 Nov 2008, /// wrote:

> While trying to come up with a workaround (a KLUDGE),

The proper kludge here is to write a little native module that provides 
set-car!/set-cdr!. See attached file (completely unsafe, use at your own 
risk)

Use like this:


Now, where is my flame shield?


-- vyzo
-------------- next part --------------
// hack for providing set-car!/set-cdr! in mz4
// author: vyzo
// USE AT YOUR OWN RISK
#include "escheme.h"

#define SYMBOL scheme_intern_symbol
#define DEFUN(name, p, mina, maxa) \
  scheme_add_global (name, \
    scheme_make_prim_w_arity (p, name, mina, maxa), module)

START_XFORM_SKIP;
Scheme_Object *set_car (int argc, Scheme_Object **argv) {
  SCHEME_CAR (argv[0]) = argv[1];
  return scheme_void;
}

Scheme_Object *set_cdr (int argc, Scheme_Object **argv) {
  SCHEME_CDR (argv[0]) = argv[1];
  return scheme_void;
}
END_XFORM_SKIP;

Scheme_Object *scheme_reload (Scheme_Env *env) {
  Scheme_Env* module;
  module = scheme_primitive_module (SYMBOL ("_unsafe" ), env);
  DEFUN ("set-car!", set_car, 2, 2);
  DEFUN ("set-cdr!", set_cdr, 2, 2);
  scheme_finish_primitive_module( module );
  return scheme_void;
}

Scheme_Object *scheme_initialize (Scheme_Env *env) {
  return scheme_reload (env);
}

Scheme_Object *scheme_module_name() {
  return SYMBOL ("nasty");
}


Posted on the users mailing list.