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

From: Marijn (hkBst at gentoo.org)
Date: Mon Nov 28 03:10:00 EST 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Neil,

On 25-11-11 14:47, Neil Van Dyke wrote:
> 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...

All I really wanted was the mod0 function from r6rs, which I can get
without causing any further problems doing:
(require (only-in rnrs/base-6 mod0))

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

I guess I was under the mistaken impression that all this stuff was
compatible with each other. I can live with that not being so, but it
seems that it might then be a good idea to include some of the
functions that r6rs has, but racket doesn't, in some other module.

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

Thanks, I had no idea.

Marijn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7TQdgACgkQp/VmCx0OL2xVJQCgwYLCsTuAIPyNynYhVnLKjKIW
znYAoMQkfYKLuLsE50VV8REBcVcLypPT
=B68t
-----END PGP SIGNATURE-----


Posted on the dev mailing list.