Subject: Re: HOWTO resize an existing string with MzScheme??
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/01/27
Newsgroups: comp.lang.scheme
Message-ID: <86oeg3$uiqel@fido.engr.sgi.com>
Leo Razoumov  <see_signature@127.0.0.1> wrote:
+---------------
| [Q] How can I resize an existing string (increase/decrease a string length)??
| A point of clarification: resizing is *NOT* allocating a new bigger string
| and copying contents from older string to the new one. 
| Resizing should preserve eq? predicate.
+---------------

This connot be done in general, and certainly not within the bounds of R5RS.

One might be able to write a C extension that does it specifically for
MzScheme or other implementations which always store a string as two pieces
(that is, a "Scheme object" or "GC cell" containing a pointer to an
out-of-line string body), but for performance reasons some implementations
store [short] strings & vectors in-line (directly in the Scheme object),
and in that case there might well be live objects on both sides, and thus
there'd not *be* any room to grow the string.

You might also want to look at SCM's "uniform vectors" (which include
uniform vectors of character), which provide something like a Common Lisp
"fill pointer".


-Rob

-----
Rob Warnock, 8L-846		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA