Re: Remaining work on SRFI 178 Wolfgang Corcoran-Mathe 21 Aug 2020 22:38 UTC

On 2020-08-21 17:03 -0400, John Cowan wrote:
> Actually not.  Here are Olin's comments in SRFI 13, which have been carried
> over:
>
> ;;; The strategy is to allocate a series of chunks into which we stash the
> ;;; chars as we generate them. Chunk size goes up in powers of two starting
> ;;; with 40 and levelling out at 4k, i.e.
> ;;;     40 40 80 160 320 640 1280 2560 4096 4096 4096 4096 4096...
> ;;; This should work pretty well for short strings, 1-line (80 char)
> strings,
> ;;; and longer ones. When done, we allocate an answer string and copy the
> ;;; chars over from the chunk buffers.
>
> The chunks are of course kept in a list.  This is a variant of the strategy
> used for extending vectors: double it until the geometric progression
> threatens to eat you alive, and then grow arithmetically after that.

I wrote too soon and could have consulted the SRFI 13 code.  Right,
this makes perfect sense.  We obviously want to be able to unfold
arbitrary-length strings.

--
Wolfgang Corcoran-Mathe  <xxxxxx@sigwinch.xyz>

"Eventually, I decided that thinking was not getting me very far and
it was time to try building." --Rob Pike