Re: [Scheme-reports] Proposed new SRFI for immutable lists John Cowan (03 Sep 2014 21:43 UTC)
Re: [Scheme-reports] Proposed new SRFI for immutable lists Sam Tobin-Hochstadt (03 Sep 2014 22:25 UTC)

Re: [Scheme-reports] Proposed new SRFI for immutable lists John Cowan 03 Sep 2014 21:39 UTC

Michael Montague scripsit:

> I suggest that immutable pairs should use the same names (cons, car,
> cdr, pair?, etc) as mutable pairs. A programmer can control which
> implementation of pairs they use in a particular module using import.

That's exactly what I thought when I started this effort, but after
all, some Schemes don't have modules, so I figured I'd just go with the
minimal name changes.  So I wrote a script to refactor all the names in
the code (a few names of local variables got missed, I think), wrote a
bunch of tests, and started debugging.  I figured it would be a doddle.

Only not.

What I wasn't thinking of was that the mechanism of procedures with
arbitrary numbers of arguments, of which SRFI-1 and SRFI-116 have many,
involves the use of lists, not ilists.  In Racket, ordinary Scheme
lists were immutable and there was no problem.  But to make the code
work in Chicken and Chibi, where I do most of my development, I had to
scrutinize all of the converted code for map and for-each and many other
routines in order to decide when I was dealing with immutable lists and
when with mutable argument lists.

> Issue (2) could be solved by factoring (scheme base) into pieces:
> (scheme base pairs), (scheme base strings), etc.

Actually, there is nothing magic about (scheme base) except that it's
loaded by default in the REPL.  Chibi allows you to start a REPL with
an arbitrary base package, so it would be no problem to create (scheme
ilist base) and (scheme ilist list) to provide the base library and
SRFI-1 respectively, but with immutable pairs.  But if you want to
deal with arbitrary numbers of arguments, you'd still have to have the
mutable-pair operations available with prefixes.

--
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
Schlingt dreifach einen Kreis vom dies!
Schliesst euer Aug vor heiliger Schau,
Denn er genoss vom Honig-Tau,
Und trank die Milch vom Paradies.

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports