[EMAIL PROTECTED] wrote:
There are at least four schools of thought on all of this. First, I
believe that some people think a sufficiently smart compiler could hide
some/many/most of these issues by, for example, caching information or
switching to another encoding on the fly.
You could have a 16+16-bit cache that maps scalar-value-index to
byte or word offset. You'd want it an atomic value so you don't
need synchronization. This cache would be updated on each string-ref.
Since normally strings are normally accessed sequentially, each access
is effectively O(1).
Of course it's kind of ugly having a writable cache word in a read-only
string. This might hurt the memory cache in some cases. And it means
allocating a read-only string in read-only memory is difficult.
Of course string-set! is fundamentally broken and useless as I've
said numerous times. It could be replaced by:
(string-append-char! str1 ch)
(string-append-string! str1 str2)
Append ch/str2 to the end to str1. str1 is modified in-place.
--
--Per Bothner
[EMAIL PROTECTED] http://per.bothner.com/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss