[racket-dev] regexp-split produces immutable cons when rnrs/base-6 is required

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Fri Nov 25 08:47:57 EST 2011

As an immediate solution, I suggest simply not trying to use R6RS 
compatibility libraries with Racket, and instead just use the Racket 
language.  Spend your energy on your application.  (I don't want to get 
into why right now, but my book will have an entire section or chapter 
entitled "Don't Use R6RS".)

If you have some super-good reason for wanting to use R6RS, a few more 
comments...

The particular problem you're having is due to "rnrs/base-6" wanting to 
use mutable pairs, while libraries implemented in Racket want to use 
immutable pairs.  They *could* be made more interoperable, but all the 
ways I can think of would have other undesirable costs, and you'd either 
end up getting bugs in other places or get really lousy performance.

As a workaround if you *really* want to use R6RS, but also use 
"regexp-split", is to make a tiny "#lang racket/base" module that wraps 
Racket's "regexp-split" to convert any pairs in the return value to mpairs.

BTW, if you want to parse input like this from a port, you can use 
Racket regexp operations or a grammar-based parser directly on the port, 
rather than reading a line and then doing a "regexp-split" on the line.  
The latter way is a Perl idiomatic way of parsing a language like this, 
and that way will also work in Racket, but there are arguably better ways.

-- 
http://www.neilvandyke.org/



Posted on the dev mailing list.