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

2011-11-28 Thread Marijn
-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-
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


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

2011-11-25 Thread Marijn
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

regexp-split produces an immutable cons when rnrs/base-6 is required:

$ echo m | racket -e '(require rnrs/base-6) (car (regexp-split  +
(read-line (current-input-port
'mcar: expects argument of type mutable-pair; given '(m)

but

$ echo m | racket -e '(require rnrs/base-6) (car (list (read-line
(current-input-port'
m

so apparently regexp-split is the culprit,

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

iEYEARECAAYFAk7PlOEACgkQp/VmCx0OL2wlTwCgwTewaztqNFFkqtQxj9Yh2ELB
/FkAnjA9OksH4ziOdIP33C5SdveRx960
=Mw9C
-END PGP SIGNATURE-
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


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

2011-11-25 Thread Sam Tobin-Hochstadt
On Fri, Nov 25, 2011 at 8:15 AM, Marijn hk...@gentoo.org wrote:

 regexp-split produces an immutable cons when rnrs/base-6 is required:

`regexp-split' is still being obtained from `racket/base' in this example:

 $ echo m | racket -e '(require rnrs/base-6) (car (regexp-split  +
 (read-line (current-input-port
 'mcar: expects argument of type mutable-pair; given '(m)

 but

but all of these bindings are shadowed by `rnrs/base-6', and so
manipulate mutable pairs.

 $ echo m | racket -e '(require rnrs/base-6) (car (list (read-line
 (current-input-port'
 m

 so apparently regexp-split is the culprit,

R6RS doesn't specify regular expressions, so there isn't a custom
version of the regular expression functionality that works with R6RS
(ie, mutable) lists.
-- 
sam th
sa...@ccs.neu.edu
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


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

2011-11-25 Thread Neil Van Dyke
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/

_
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/dev